using FrameworkBLL.GBPeriod; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; using FastEndpoints; using System.Threading; using System.Threading.Tasks; namespace FrameworkSL.Endpoints.GBPeriod { public class GetSelectListGBPeriod : BaseEndpoint> { private readonly IGBPeriodBLL _gbPeriodBLL; public GetSelectListGBPeriod(IGBPeriodBLL gbPeriodBLL) { _gbPeriodBLL = gbPeriodBLL; } public override void Configure() { Post("/GBPeriod/GetSelectListGBPeriod"); AllowAnonymous(); } public record GetSelectListGBPeriodParameters( [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override async Task> ExecuteAsync(GetSelectListGBPeriodParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _gbPeriodBLL.GetSelectListGBPeriod( req.FirstNumber, req.MaxResult, req.CriteriaDTO, LoginDTO! ); 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 ); } } } }