using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.PayPeriod; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.PayPeriod { // GB4 parity: PayPeriod.svc/SelectList/Descending/?FirstNumber={FirstNumber}&MaxResult={MaxResult} public class PayPeriodSelectListDescending : BaseEndpoint { private readonly IPayPeriodBLL _payPeriodBLL; public PayPeriodSelectListDescending(IPayPeriodBLL IPayPeriodBLL) { _payPeriodBLL = IPayPeriodBLL; } public override void Configure() { Post("/PayPeriod/SelectListDescending"); AllowAnonymous(); } protected override async Task> ExecuteAsync(PayPeriodSelectListDescendingParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _payPeriodBLL.GetSelectListPayPeriodDescendingOrder(req.FirstNumber, req.MaxResult, req.CriteriaDTO, LoginDTO!, false); int Total = Convert.ToInt32(await _payPeriodBLL.GetSelectListPayPeriodDescendingOrder(-1, -1, req.CriteriaDTO, LoginDTO!, true)); var Response = await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); Response.Total = Total; return Response; } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } public record PayPeriodSelectListDescendingParameters( [property: FastEndpoints.QueryParam] int FirstNumber, [property: FastEndpoints.QueryParam] int MaxResult, [property: FastEndpoints.FromBody] CriteriaDTO CriteriaDTO, [property: FastEndpoints.FromHeader] LoginDTO Login ); } }