Search Results for

    Show / Hide Table of Contents

    Class TemplateService

    Implementation of the template service for managing email, process, and event templates.

    Inheritance
    object
    TemplateService
    Implements
    ITemplateService
    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 TemplateService : ITemplateService

    Constructors

    TemplateService(IEmailTemplateRepository, IProcessTemplateRepository, IEventTemplateRepository, IProcessStepTemplateRepository, IUserRepository, IDbContextFactory<OEMSDBContext>, IMapper)

    Initializes a new instance of the TemplateService class.

    Declaration
    public TemplateService(IEmailTemplateRepository emailTemplateRepository, IProcessTemplateRepository processTemplateRepository, IEventTemplateRepository eventTemplateRepository, IProcessStepTemplateRepository processStepTemplateRepository, IUserRepository userRepository, IDbContextFactory<OEMSDBContext> contextFactory, IMapper mapper)
    Parameters
    Type Name Description
    IEmailTemplateRepository emailTemplateRepository

    Repository for email template operations

    IProcessTemplateRepository processTemplateRepository

    Repository for process template operations

    IEventTemplateRepository eventTemplateRepository

    Repository for event template operations

    IProcessStepTemplateRepository processStepTemplateRepository

    Repository for process step template operations

    IUserRepository userRepository

    Repository for user operations

    IDbContextFactory<OEMSDBContext> contextFactory

    DbContext factory for creating separate contexts to avoid concurrency issues

    IMapper mapper

    AutoMapper instance for object mapping

    Methods

    CreateEmailTemplateAsync(Guid, CreateEmailTemplateDto)

    Creates a new email template in the system

    Declaration
    public Task<Guid> CreateEmailTemplateAsync(Guid userId, CreateEmailTemplateDto dto)
    Parameters
    Type Name Description
    Guid userId

    The ID of the user creating the template

    CreateEmailTemplateDto dto

    The data transfer object containing the email template details

    Returns
    Type Description
    Task<Guid>

    The ID of the newly created email template

    Exceptions
    Type Condition
    UnauthorizedAccessException

    Thrown when the user doesn't have permission to create templates in the organization

    CreateEventTemplateAsync(Guid, Guid, CreateEventTemplateDto)

    Declaration
    public Task<Guid> CreateEventTemplateAsync(Guid userId, Guid organizationId, CreateEventTemplateDto dto)
    Parameters
    Type Name Description
    Guid userId
    Guid organizationId
    CreateEventTemplateDto dto
    Returns
    Type Description
    Task<Guid>
    Exceptions
    Type Condition
    UnauthorizedAccessException

    CreateProcessStepTemplateAsync(Guid, CreateProcessStepTemplateDto)

    Creates process step template

    Declaration
    public Task<Guid> CreateProcessStepTemplateAsync(Guid userId, CreateProcessStepTemplateDto dto)
    Parameters
    Type Name Description
    Guid userId

    user GUID of user wanting to create a process step template

    CreateProcessStepTemplateDto dto

    CreateProcessStepTemplateDto

    Returns
    Type Description
    Task<Guid>

    GUID of created template

    Exceptions
    Type Condition
    KeyNotFoundException

    CreateProcessTemplateAsync(Guid, CreateProcessTemplateDto)

    Creates process template

    Declaration
    public Task<Guid> CreateProcessTemplateAsync(Guid userId, CreateProcessTemplateDto dto)
    Parameters
    Type Name Description
    Guid userId

    user GUID of user creating the template

    CreateProcessTemplateDto dto

    CreateProcessTemplateDto

    Returns
    Type Description
    Task<Guid>

    DeleteEmailTemplateAsync(Guid, Guid)

    Deletes an email template from the system

    Declaration
    public Task DeleteEmailTemplateAsync(Guid userId, Guid id)
    Parameters
    Type Name Description
    Guid userId

    The ID of the user deleting the template

    Guid id

    The ID of the email template to delete

    Returns
    Type Description
    Task

    A task representing the asynchronous operation

    Exceptions
    Type Condition
    KeyNotFoundException

    Thrown when the email template with the specified ID is not found

    UnauthorizedAccessException

    Thrown when the user doesn't have permission to delete templates in the organization

    DeleteProcessStepTemplateAsync(Guid, Guid)

    Deletes a process step template

    Declaration
    public Task DeleteProcessStepTemplateAsync(Guid userId, Guid id)
    Parameters
    Type Name Description
    Guid userId

    user GUID of user wanting to delete template

    Guid id

    process step template GUID to be deleted

    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    DeleteProcessTemplateAsync(Guid, Guid)

    Deletes a process template. Checks if template associated with process. If so, does not delete

    Declaration
    public Task DeleteProcessTemplateAsync(Guid userId, Guid id)
    Parameters
    Type Name Description
    Guid userId
    Guid id
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException
    InvalidOperationException

    DeleteTemplateAsync(Guid)

    Deletes an event template.

    Declaration
    public Task DeleteTemplateAsync(Guid templateId)
    Parameters
    Type Name Description
    Guid templateId

    The unique identifier of the template to delete.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    GetAllEmailTemplatesByOrganizationAsync(Guid)

    Retrieves all email templates for a specific organization without checking user permissions

    Declaration
    public Task<IEnumerable<EmailTemplateDto>> GetAllEmailTemplatesByOrganizationAsync(Guid organizationId)
    Parameters
    Type Name Description
    Guid organizationId

    The ID of the organization whose templates are being requested. If empty, retrieves templates from all organizations

    Returns
    Type Description
    Task<IEnumerable<EmailTemplateDto>>

    A collection of email template DTOs

    Exceptions
    Type Condition
    Exception

    Thrown when an error occurs during template retrieval

    GetAllProcessStepTemplatesByOrganizationAsync(Guid)

    Gets all processstep templates for an organization. Gets a process step template by Id. Checks if user has permission to manage processstep templates for oganization

    Declaration
    public Task<IEnumerable<ProcessStepTemplateDto>> GetAllProcessStepTemplatesByOrganizationAsync(Guid organizationId)
    Parameters
    Type Name Description
    Guid organizationId
    Returns
    Type Description
    Task<IEnumerable<ProcessStepTemplateDto>>

    IEnumerable of type ProcessStepTemplateDto

    GetAllProcessTemplatesByOrganizationAsync(Guid)

    Gets all proccess templates for an organization. Does not need user GUID

    Declaration
    public Task<IEnumerable<ProcessTemplateDto>> GetAllProcessTemplatesByOrganizationAsync(Guid organizationId)
    Parameters
    Type Name Description
    Guid organizationId

    GUID org for which all templates are requested

    Returns
    Type Description
    Task<IEnumerable<ProcessTemplateDto>>

    GetEmailTemplatesAsync(Guid, Guid)

    Retrieves all email templates for a specific organization that the user has access to

    Declaration
    public Task<IEnumerable<EmailTemplateDto>> GetEmailTemplatesAsync(Guid userId, Guid organizationId)
    Parameters
    Type Name Description
    Guid userId

    The ID of the user requesting the templates

    Guid organizationId

    The ID of the organization whose templates are being requested

    Returns
    Type Description
    Task<IEnumerable<EmailTemplateDto>>

    A collection of email template DTOs

    Exceptions
    Type Condition
    UnauthorizedAccessException

    Thrown when the user doesn't have permission to view templates in the organization

    GetEventTemplatesAsync(Guid, Guid)

    Retrieves event templates accessible to a user within an organization.

    Declaration
    public Task<IEnumerable<EventTemplateDto>> GetEventTemplatesAsync(Guid userId, Guid organizationId)
    Parameters
    Type Name Description
    Guid userId

    The unique identifier of the user.

    Guid organizationId

    The unique identifier of the organization.

    Returns
    Type Description
    Task<IEnumerable<EventTemplateDto>>

    A task that represents the asynchronous operation. The task result contains a collection of event template data transfer objects.

    GetEventTemplatesByOrganizationAsync(Guid)

    Retrieves all event templates for a specific organization.

    Declaration
    public Task<List<EventTemplateDto>> GetEventTemplatesByOrganizationAsync(Guid organizationId)
    Parameters
    Type Name Description
    Guid organizationId

    The unique identifier of the organization.

    Returns
    Type Description
    Task<List<EventTemplateDto>>

    A task that represents the asynchronous operation. The task result contains a list of event template data transfer objects.

    GetOrganizationsForUserAsync(Guid)

    Get a list of organization IDs that the user has access to

    Declaration
    public Task<List<Guid>> GetOrganizationsForUserAsync(Guid userId)
    Parameters
    Type Name Description
    Guid userId

    The ID of the user

    Returns
    Type Description
    Task<List<Guid>>

    A list of organization IDs that the user has access to

    GetProcessStepTemplateByIdAsync(Guid, Guid)

    Gets a process step template by Id. Checks if user has permission to manage processstep templates for oganization. Uses Auto Mapper

    Declaration
    public Task<ProcessStepTemplateDto> GetProcessStepTemplateByIdAsync(Guid userId, Guid id)
    Parameters
    Type Name Description
    Guid userId

    user GUID

    Guid id

    Process Step Template GUID

    Returns
    Type Description
    Task<ProcessStepTemplateDto>
    Exceptions
    Type Condition
    KeyNotFoundException

    GetProcessStepTemplatesByProcessTemplateIdAsync(Guid, Guid)

    Gets Process Step Templates for a specific process. Checks isf user has permission to do so

    Declaration
    public Task<IEnumerable<ProcessStepTemplateDto>> GetProcessStepTemplatesByProcessTemplateIdAsync(Guid userId, Guid processTemplateId)
    Parameters
    Type Name Description
    Guid userId
    Guid processTemplateId
    Returns
    Type Description
    Task<IEnumerable<ProcessStepTemplateDto>>

    IEnumerable of type ProcessStepTemplate Dto

    Exceptions
    Type Condition
    KeyNotFoundException

    GetProcessTemplateByIdAsync(Guid, Guid)

    Gets a singel process template

    Declaration
    public Task<ProcessTemplateDto> GetProcessTemplateByIdAsync(Guid userId, Guid id)
    Parameters
    Type Name Description
    Guid userId

    user GUID of user requesting template

    Guid id

    GUID of template

    Returns
    Type Description
    Task<ProcessTemplateDto>
    Exceptions
    Type Condition
    KeyNotFoundException

    GetProcessTemplatesAsync(Guid, Guid)

    Gets all process templates for an organization

    Declaration
    public Task<IEnumerable<ProcessTemplateDto>> GetProcessTemplatesAsync(Guid userId, Guid organizationId)
    Parameters
    Type Name Description
    Guid userId

    user GUID of user requesting all templates

    Guid organizationId

    organization GUID

    Returns
    Type Description
    Task<IEnumerable<ProcessTemplateDto>>

    UpdateEmailTemplateAsync(Guid, UpdateEmailTemplateDto)

    Updates an existing email template

    Declaration
    public Task UpdateEmailTemplateAsync(Guid userId, UpdateEmailTemplateDto dto)
    Parameters
    Type Name Description
    Guid userId

    The ID of the user updating the template

    UpdateEmailTemplateDto dto

    The data transfer object containing the updated email template details

    Returns
    Type Description
    Task

    A task representing the asynchronous operation

    Exceptions
    Type Condition
    KeyNotFoundException

    Thrown when the email template with the specified ID is not found

    UnauthorizedAccessException

    Thrown when the user doesn't have permission to update templates in the organization

    UpdateProcessStepTemplateAsync(Guid, UpdateProcessStepTemplateDto)

    Updates a process step template

    Declaration
    public Task UpdateProcessStepTemplateAsync(Guid userId, UpdateProcessStepTemplateDto dto)
    Parameters
    Type Name Description
    Guid userId
    UpdateProcessStepTemplateDto dto
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    UpdateProcessStepTemplateSequenceAsync(Guid, Guid, int)

    Updates a process step template

    Declaration
    public Task UpdateProcessStepTemplateSequenceAsync(Guid userId, Guid id, int newSequence)
    Parameters
    Type Name Description
    Guid userId

    user GUID

    Guid id
    int newSequence
    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    UpdateProcessTemplateAsync(Guid, UpdateProcessTemplateDto)

    Updates Process template

    Declaration
    public Task UpdateProcessTemplateAsync(Guid userId, UpdateProcessTemplateDto dto)
    Parameters
    Type Name Description
    Guid userId

    user GUID of user changing template

    UpdateProcessTemplateDto dto

    UpdateProcesstemplateDto of template to be changed

    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    KeyNotFoundException

    UpdateTemplateAsync(Guid, UpdateEventTemplateDto)

    Updates an existing event template.

    Declaration
    public Task UpdateTemplateAsync(Guid templateId, UpdateEventTemplateDto dto)
    Parameters
    Type Name Description
    Guid templateId

    The unique identifier of the template to update.

    UpdateEventTemplateDto dto

    The event template update data transfer object.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    Implements

    ITemplateService
    In this article
    Back to top Generated by DocFX