using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.PayProcess; using PayRollDAL.DTO.PayProcess; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Leave { public class LeaveStatusReport : BaseEndpoint> { private readonly IPayProcessBLL _PayProcessBLL; public LeaveStatusReport(IPayProcessBLL payProcessBLL) { _PayProcessBLL = payProcessBLL; } public override void Configure() { Post("/Leave/LeaveStatusReport"); AllowAnonymous(); } public record LeaveStatusReportParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async Task> ExecuteAsync(LeaveStatusReportParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { string json = await _PayProcessBLL.LeaveStatusReportAsync(req.FirstNumber, req.MaxResult, req.CriteriaDTO, LoginDTO!); var result = string.IsNullOrEmpty(json) ? new List() : Newtonsoft.Json.JsonConvert.DeserializeObject>(json) ?? new List(); 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); } } } }