using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.TLeave; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.TLeave { public class GetTLeaveDetails : BaseEndpoint> { private readonly ITLeaveBLL _TLeaveBLL; public GetTLeaveDetails(ITLeaveBLL tLeaveBLL) { _TLeaveBLL = tLeaveBLL; } public override void Configure() { Post("/TLeave/GetTLeaveDetails"); AllowAnonymous(); } public record GetTLeaveDetailsParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async Task> ExecuteAsync( GetTLeaveDetailsParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _TLeaveBLL.GetTLeaveDetails(req.FirstNumber, req.MaxResult, req.CriteriaDTO, loginDTO); var response = await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, loginDTO); string totalJson = await _TLeaveBLL.GetTLeaveDetails(req.FirstNumber, req.MaxResult, req.CriteriaDTO, loginDTO, true); response.Total = Convert.ToInt32(totalJson); return response; } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }