using FastEndpoints; using FrameworkBLL.MailTemplate; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.MailTemplate { public class GetMailTemplate : BaseEndpoint { private readonly IMailTemplateBLL _MailTemplateBLL; public GetMailTemplate(IMailTemplateBLL MailTemplateBLL) { _MailTemplateBLL = MailTemplateBLL; } public override void Configure() { Get("/MailTemplate/GetMailTemplate"); AllowAnonymous(); } public record GetMailTemplateParameters( [property: QueryParam] int MailTemplateId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetMailTemplateParameters GetMailTemplateParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetMailTemplateParameters.MailTemplateId!, EntityConstant.OBJECTMAILTEMPLATE, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetMailTemplateParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _MailTemplateBLL.GetMailTemplate(parameters.MailTemplateId, loginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, loginDTO, ex.Message, 500); } } } }