using FastEndpoints; using FrameworkBLL.Template; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Template { // Returns Id / Code / Name (MTEMPLATE) for dropdown population. public class GetSelectListTemplate : BaseEndpoint> { private readonly ITemplateBLL _TemplateBLL; public GetSelectListTemplate(ITemplateBLL ITemplateBLL) { _TemplateBLL = ITemplateBLL; } public override void Configure() { Post("/Template/GetSelectListTemplate"); AllowAnonymous(); } public record GetSelectListTemplateParameters( [property: FromHeader] string Login ); protected override string? GetCacheKey(GetSelectListTemplateParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(LoginDTO.ClientId, EntityConstant.OBJECTTEMPLATE, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetSelectListTemplateParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _TemplateBLL.GetSelectListTemplate(LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }