using AdminBLL.TemplateData; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.TemplateData { public class GetTemplateData : BaseEndpoint> { private readonly ITemplateDataBLL _TemplateDataBLL; public GetTemplateData(ITemplateDataBLL TemplateDataBLL) { _TemplateDataBLL = TemplateDataBLL; } public override void Configure() { Get("/TemplateData/GetTemplateData"); AllowAnonymous(); } public record GetTemplateDataParameters( [property: FromHeader] string Login, [property: QueryParam] int TemplateDataId ); // TemplateData rows are transactional/form-submission records — per this repo's own // caching rules, never cache financial/transactional data, so this always returns null // rather than computing a real cache key. protected override string? GetCacheKey(GetTemplateDataParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(GetTemplateDataParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _TemplateDataBLL.GetTemplateData(req.TemplateDataId, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }