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)

    Creates a new event template.

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

    The unique identifier of the user creating the template.

    Guid organizationId

    The unique identifier of the organization.

    CreateEventTemplateDto dto

    The event template creation data transfer object.

    Returns
    Type Description
    Task<Guid>

    A task that represents the asynchronous operation. The task result contains the newly created template's identifier.

    CreateProcessStepTemplateAsync(Guid, CreateProcessStepTemplateDto)

    Creates a new process step template.

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

    The unique identifier of the user creating the template.

    CreateProcessStepTemplateDto dto

    The process step template creation data transfer object.

    Returns
    Type Description
    Task<Guid>

    A task that represents the asynchronous operation. The task result contains the newly created template's identifier.

    CreateProcessTemplateAsync(Guid, CreateProcessTemplateDto)

    Creates a new process template.

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

    The unique identifier of the user creating the template.

    CreateProcessTemplateDto dto

    The process template creation data transfer object.

    Returns
    Type Description
    Task<Guid>

    A task that represents the asynchronous operation. The task result contains the newly created template's identifier.

    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

    The unique identifier of the user deleting the template.

    Guid id

    The unique identifier of the template to delete.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    DeleteProcessTemplateAsync(Guid, Guid)

    Deletes a process template.

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

    The unique identifier of the user deleting the template.

    Guid id

    The unique identifier of the template to delete.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    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)

    Retrieves all process step templates for a specific organization.

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

    The unique identifier of the organization.

    Returns
    Type Description
    Task<IEnumerable<ProcessStepTemplateDto>>

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

    GetAllProcessTemplatesByOrganizationAsync(Guid)

    Retrieves all process templates for a specific organization.

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

    The unique identifier of the organization.

    Returns
    Type Description
    Task<IEnumerable<ProcessTemplateDto>>

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

    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)

    Retrieves a specific process step template by its identifier.

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

    The unique identifier of the user requesting the template.

    Guid id

    The unique identifier of the process step template.

    Returns
    Type Description
    Task<ProcessStepTemplateDto>

    A task that represents the asynchronous operation. The task result contains the process step template data transfer object.

    GetProcessStepTemplatesByProcessTemplateIdAsync(Guid, Guid)

    Retrieves all process step templates for a specific process template.

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

    The unique identifier of the user requesting the templates.

    Guid processTemplateId

    The unique identifier of the process template.

    Returns
    Type Description
    Task<IEnumerable<ProcessStepTemplateDto>>

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

    GetProcessTemplateByIdAsync(Guid, Guid)

    Retrieves a specific process template by its identifier.

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

    The unique identifier of the user requesting the template.

    Guid id

    The unique identifier of the process template.

    Returns
    Type Description
    Task<ProcessTemplateDto>

    A task that represents the asynchronous operation. The task result contains the process template data transfer object.

    GetProcessTemplatesAsync(Guid, Guid)

    Retrieves process templates accessible to a user within an organization.

    Declaration
    public Task<IEnumerable<ProcessTemplateDto>> GetProcessTemplatesAsync(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<ProcessTemplateDto>>

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

    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 an existing process step template.

    Declaration
    public Task UpdateProcessStepTemplateAsync(Guid userId, UpdateProcessStepTemplateDto dto)
    Parameters
    Type Name Description
    Guid userId

    The unique identifier of the user updating the template.

    UpdateProcessStepTemplateDto dto

    The process step template update data transfer object.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    UpdateProcessStepTemplateSequenceAsync(Guid, Guid, int)

    Updates the sequence order of a process step template.

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

    The unique identifier of the user updating the sequence.

    Guid id

    The unique identifier of the process step template.

    int newSequence

    The new sequence number for the process step.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    UpdateProcessTemplateAsync(Guid, UpdateProcessTemplateDto)

    Updates an existing process template.

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

    The unique identifier of the user updating the template.

    UpdateProcessTemplateDto dto

    The process template update data transfer object.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    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