using AdminBLL.FormTemplate; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.FormTemplate { public class GetFormTemplate : BaseEndpoint> { private readonly IFormTemplateBLL _FormTemplateBLL; public GetFormTemplate(IFormTemplateBLL FormTemplateBLL) { _FormTemplateBLL = FormTemplateBLL; } public override void Configure() { Get("/FormTemplate/GetFormTemplate"); AllowAnonymous(); } public record GetFormTemplateParameters( [property: FromHeader] string Login, [property: QueryParam] int FormTemplateId ); protected override string? GetCacheKey(GetFormTemplateParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.FormTemplateId, EntityConstant.OBJECTFORMTEMPLATE, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetFormTemplateParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _FormTemplateBLL.GetFormTemplate(req.FormTemplateId, LoginDTO!, ct); 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); } } } }