Search Results for

    Show / Hide Table of Contents

    Class OrganizationService

    Service for managing organizations

    Inheritance
    object
    OrganizationService
    Implements
    IOrganizationService
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: OEMS.Core.Application.ApplicationServices
    Assembly: OEMS.Core.dll
    Syntax
    public class OrganizationService : IOrganizationService

    Constructors

    OrganizationService(IUserRepository, IOrganisationUserRepository, IOrganizationRepository, IMapper, IFileRepository, ITokenService, IAuthService, ILogger<OrganizationService>, IConfiguration, IDbContextFactory<OEMSDBContext>, IEventCategoryRepository, ILocationRepository)

    Initializes a new instance of the OrganizationService

    Declaration
    public OrganizationService(IUserRepository userRepository, IOrganisationUserRepository organizationUserRepository, IOrganizationRepository organizationRepository, IMapper mapper, IFileRepository fileRepository, ITokenService tokenService, IAuthService authService, ILogger<OrganizationService> logger, IConfiguration configuration, IDbContextFactory<OEMSDBContext> contextFactory, IEventCategoryRepository eventCategoryRepository, ILocationRepository locationRepository)
    Parameters
    Type Name Description
    IUserRepository userRepository
    IOrganisationUserRepository organizationUserRepository
    IOrganizationRepository organizationRepository
    IMapper mapper
    IFileRepository fileRepository
    ITokenService tokenService
    IAuthService authService
    ILogger<OrganizationService> logger
    IConfiguration configuration
    IDbContextFactory<OEMSDBContext> contextFactory
    IEventCategoryRepository eventCategoryRepository
    ILocationRepository locationRepository

    Methods

    AssignOrgAdminAsync(Guid, Guid)

    Assigns administrator privileges to a user within an organization.

    Declaration
    public Task AssignOrgAdminAsync(Guid orgId, Guid userId)
    Parameters
    Type Name Description
    Guid orgId

    The unique identifier of the organization.

    Guid userId

    The unique identifier of the user to make an administrator.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    CheckIfEventAtLocation(Guid, Guid)

    Checks if a location is associated with an event.

    Declaration
    public Task<(bool, List<string>)> CheckIfEventAtLocation(Guid orgId, Guid locationId)
    Parameters
    Type Name Description
    Guid orgId

    org GUID

    Guid locationId

    location GUID

    Returns
    Type Description
    Task<(bool hasAny, List<string> eventNames)>

    bool. True if location is associated with an event

    CheckIfEventWithCategory(Guid, Guid)

    Declaration
    public Task<(bool hasAny, List<string> categoryNames)> CheckIfEventWithCategory(Guid orgId, Guid categoryId)
    Parameters
    Type Name Description
    Guid orgId
    Guid categoryId
    Returns
    Type Description
    Task<(bool hasAny, List<string> eventNames)>

    CreateEventCategory(Guid, CreateCategoryDto)

    Creates a new event category for the given organization. Checks if the category name already exists.

    Declaration
    public Task CreateEventCategory(Guid orgId, CreateCategoryDto createCategoryDto)
    Parameters
    Type Name Description
    Guid orgId
    CreateCategoryDto createCategoryDto
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    InvalidOperationException

    CreateLocation(Guid, CreateLocationDto)

    Creates a new location for the given organization. Checks if the location name already exists.

    Declaration
    public Task CreateLocation(Guid orgId, CreateLocationDto locationDto)
    Parameters
    Type Name Description
    Guid orgId
    CreateLocationDto locationDto
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    InvalidOperationException

    CreateOrganizationAsync(CreateOrganizationDto)

    Creates a new organization with admin registration token

    Declaration
    public Task<OrganizationCreationResultDto> CreateOrganizationAsync(CreateOrganizationDto dto)
    Parameters
    Type Name Description
    CreateOrganizationDto dto
    Returns
    Type Description
    Task<OrganizationCreationResultDto>

    CreateOrganizationLegacyAsync(CreateOrganizationDto)

    Legacy method for creating organization (to be deprecated)

    Declaration
    public Task<CreateOrganizationDto> CreateOrganizationLegacyAsync(CreateOrganizationDto dto)
    Parameters
    Type Name Description
    CreateOrganizationDto dto
    Returns
    Type Description
    Task<CreateOrganizationDto>

    DeleteCategoryByIdAsync(Guid)

    Deletes an event category by its unique identifier.

    Declaration
    public Task DeleteCategoryByIdAsync(Guid categoryId)
    Parameters
    Type Name Description
    Guid categoryId

    The unique identifier of the category to delete.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    DeleteEventCategoryAsync(Guid)

    Deletes an event category by its ID. Throws an exception if the category is null.

    Declaration
    public Task DeleteEventCategoryAsync(Guid eventCategoryId)
    Parameters
    Type Name Description
    Guid eventCategoryId
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    DeleteLocationByIdAsync(Guid)

    Deletes a location by its ID. Throws an exception if the location is null.

    Declaration
    public Task DeleteLocationByIdAsync(Guid locationId)
    Parameters
    Type Name Description
    Guid locationId
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    DeleteMemberAsync(Guid, Guid)

    Removes a member from an organization. Checks if member is last orgAdmin. If so,cant be removed.

    Declaration
    public Task DeleteMemberAsync(Guid userId, Guid organizationId)
    Parameters
    Type Name Description
    Guid userId

    user GUID

    Guid organizationId

    organization GUID

    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    InvalidOperationException
    Exception

    DeleteOrganizationAsync(Guid)

    Deletes an organization from the system.

    Declaration
    public Task DeleteOrganizationAsync(Guid orgId)
    Parameters
    Type Name Description
    Guid orgId

    The unique identifier of the organization to delete.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    GetAllCategorysByOrganizationAsync(Guid)

    Gets a list of all categorys for an organization

    Declaration
    public Task<List<EventCategoryDto>> GetAllCategorysByOrganizationAsync(Guid organizationId)
    Parameters
    Type Name Description
    Guid organizationId
    Returns
    Type Description
    Task<List<EventCategoryDto>>

    List of Type EventCategoryDto

    GetAllLocationsByOrganizationAsync(Guid)

    Gets all locations for a given organization, here the currently selected one

    Declaration
    public Task<List<LocationDto>> GetAllLocationsByOrganizationAsync(Guid organizationId)
    Parameters
    Type Name Description
    Guid organizationId
    Returns
    Type Description
    Task<List<LocationDto>>

    List of type LocationDto

    GetAllOrganizationsAsync(Guid)

    Gets all organizations for a user.

    Declaration
    public Task<IEnumerable<OrganizationDto>> GetAllOrganizationsAsync(Guid userId)
    Parameters
    Type Name Description
    Guid userId
    Returns
    Type Description
    Task<IEnumerable<OrganizationDto>>

    GetOrganisationByIdAsync(Guid)

    Gets an organization by its ID. Throws an exception if the organization is null.

    Declaration
    public Task<Organization> GetOrganisationByIdAsync(Guid orgId)
    Parameters
    Type Name Description
    Guid orgId
    Returns
    Type Description
    Task<Organization>
    Exceptions
    Type Condition
    KeyNotFoundException

    GetOrganizationBrandingAsync(Guid)

    Retrieves organization branding settings for the specified organization.

    Declaration
    public Task<OrganizationDto?> GetOrganizationBrandingAsync(Guid organizationId)
    Parameters
    Type Name Description
    Guid organizationId

    The unique identifier of the organization to retrieve branding for

    Returns
    Type Description
    Task<OrganizationDto>

    An OrganizationDto containing the organization's branding information including colors and logo, or null if the organization is not found

    Remarks

    This method is primarily used by the organization settings UI to load current branding configuration. The returned DTO includes all organization details with focus on branding-related properties like BrandingSettings (JSON color configuration) and FileID (logo reference).

    Examples
    var branding = await organizationService.GetOrganizationBrandingAsync(organizationId);
    if (branding != null)
    {
        var colors = JsonSerializer.Deserialize<JsonElement>(branding.BrandingSettings);
        var primaryColor = colors.GetProperty("color1").GetString();
    }

    GetOrganizationDashboardInformation(Guid)

    Gets the organization dashboard information for a user.

    Declaration
    public Task<IEnumerable<OrganizationDashboardDto>> GetOrganizationDashboardInformation(Guid userId)
    Parameters
    Type Name Description
    Guid userId

    user GUID

    Returns
    Type Description
    Task<IEnumerable<OrganizationDashboardDto>>

    GetOrganizationMembersAsync(Guid)

    Gets all members of an organization.

    Declaration
    public Task<List<MemberDto>> GetOrganizationMembersAsync(Guid organizationId)
    Parameters
    Type Name Description
    Guid organizationId
    Returns
    Type Description
    Task<List<MemberDto>>

    InviteMemberAsync(string, Guid)

    Invites a new member to join an organization by email.

    Declaration
    public Task InviteMemberAsync(string email, Guid organizationId)
    Parameters
    Type Name Description
    string email

    The email address of the person to invite.

    Guid organizationId

    The unique identifier of the organization.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    RemoveOrgAdminAsync(Guid, Guid)

    Removes administrator privileges from a user within an organization.

    Declaration
    public Task RemoveOrgAdminAsync(Guid orgId, Guid userId)
    Parameters
    Type Name Description
    Guid orgId

    The unique identifier of the organization.

    Guid userId

    The unique identifier of the user to remove administrator privileges from.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    ShowAllCategories(Guid)

    Declaration
    public Task ShowAllCategories(Guid orgID)
    Parameters
    Type Name Description
    Guid orgID
    Returns
    Type Description
    Task

    ShowAllLocations(Guid)

    Declaration
    public Task ShowAllLocations(Guid orgID)
    Parameters
    Type Name Description
    Guid orgID
    Returns
    Type Description
    Task

    TransferOrganizationAdminAsync(Guid, Guid, Guid)

    Transfers organization admin rights from one user to another.

    Declaration
    public Task TransferOrganizationAdminAsync(Guid organizationId, Guid currentAdminUserId, Guid newAdminUserId)
    Parameters
    Type Name Description
    Guid organizationId

    The organization ID

    Guid currentAdminUserId

    The current admin user ID

    Guid newAdminUserId

    The new admin user ID

    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    Thrown when organization or users are not found

    InvalidOperationException

    Thrown when operation cannot be performed

    UpdateCategoryByIdAsync(EventCategoryDto)

    Updates an event category

    Declaration
    public Task<EventCategoryDto> UpdateCategoryByIdAsync(EventCategoryDto updateCategoryDto)
    Parameters
    Type Name Description
    EventCategoryDto updateCategoryDto
    Returns
    Type Description
    Task<EventCategoryDto>

    EventCategoryDto of event category to be updated

    Exceptions
    Type Condition
    KeyNotFoundException

    UpdateEventCategory(EventCategoryDto)

    Updates an existing event category. Throws an exception if the category is null.

    Declaration
    public Task UpdateEventCategory(EventCategoryDto eventCategoryDto)
    Parameters
    Type Name Description
    EventCategoryDto eventCategoryDto
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    UpdateLocation(LocationDto)

    Updates an existing location. Throws an exception if the location is null.

    Declaration
    public Task UpdateLocation(LocationDto locationDto)
    Parameters
    Type Name Description
    LocationDto locationDto
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    UpdateLocationByIdAsync(LocationDto)

    Updates a location Dto

    Declaration
    public Task<LocationDto> UpdateLocationByIdAsync(LocationDto updateLocationDto)
    Parameters
    Type Name Description
    LocationDto updateLocationDto

    LocationDto of location to be updated

    Returns
    Type Description
    Task<LocationDto>
    Exceptions
    Type Condition
    KeyNotFoundException

    UpdateMemberDetailsAsync(MemberDto)

    Changes details of a member

    Declaration
    public Task UpdateMemberDetailsAsync(MemberDto member)
    Parameters
    Type Name Description
    MemberDto member

    MemberDto

    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    Exception

    UpdateMemberRolesAsync(Guid, Guid, bool, bool, bool, bool)

    Updates Member permissions

    Declaration
    public Task UpdateMemberRolesAsync(Guid userId, Guid organizationId, bool isAdmin, bool isOrganizer, bool isDesigner, bool isExternal)
    Parameters
    Type Name Description
    Guid userId

    user GUID of user whos permissions change

    Guid organizationId

    organization GUID user is a part of

    bool isAdmin

    bool for org admin permission

    bool isOrganizer

    bool for event organizer permission

    bool isDesigner

    bool for designer permission

    bool isExternal

    bool for external profiles

    Returns
    Type Description
    Task

    UpdateOrganizationAsync(UpdateOrganizationDto)

    Updates an existing organization's information.

    Declaration
    public Task UpdateOrganizationAsync(UpdateOrganizationDto dto)
    Parameters
    Type Name Description
    UpdateOrganizationDto dto

    The organization update data transfer object.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    UpdateOrganizationBrandingAsync(Guid, string, Guid?)

    Updates organization branding settings including colors and optionally the logo.

    Declaration
    public Task<bool> UpdateOrganizationBrandingAsync(Guid organizationId, string brandingSettings, Guid? logoFileId = null)
    Parameters
    Type Name Description
    Guid organizationId

    The unique identifier of the organization to update

    string brandingSettings

    JSON string containing branding configuration. Expected format: { "color1": "#primaryColor", "color2": "#secondaryColor" }

    Guid? logoFileId

    Optional file ID for a new organization logo. If provided and not empty, the organization's logo will be updated. If null or empty, the existing logo is preserved.

    Returns
    Type Description
    Task<bool>

    True if the update was successful, false otherwise

    Remarks

    This method is used by the organization settings UI to save branding changes made by OrgAdmin users. The branding settings should be valid JSON in the expected format. The method preserves the existing logo if no new logo file ID is provided, allowing for color-only updates.

    Examples
    // Update only colors, preserve existing logo
    var newBranding = "{ \"color1\": \"#ff0000\", \"color2\": \"#00ff00\" }";
    var success = await organizationService.UpdateOrganizationBrandingAsync(orgId, newBranding);
    
    // Update colors and logo
    var success2 = await organizationService.UpdateOrganizationBrandingAsync(orgId, newBranding, newLogoFileId);
    Exceptions
    Type Condition
    KeyNotFoundException

    Thrown when the specified organization ID does not exist in the database

    Implements

    IOrganizationService
    In this article
    Back to top Generated by DocFX