using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.OverTime; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.OverTime { // GB4 route: OverTime.svc/OverTimeDetail/?FirstNumber={FirstNumber}&MaxResult={MaxResult} (POST) // Operation contract name in GB4 is "GetOverTimeDetailReport", but the URI segment is // "/OverTimeDetail" (not "/GetOverTimeDetailReport") — preserved here deliberately since // that is the ported contract. public class GetOverTimeDetailReport : BaseEndpoint> { private readonly IOverTimeBLL _OverTimeBLL; public GetOverTimeDetailReport(IOverTimeBLL OverTimeBLL) { _OverTimeBLL = OverTimeBLL; } public override void Configure() { Post("/OverTime/OverTimeDetail"); AllowAnonymous(); } public record GetOverTimeDetailReportParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async Task> ExecuteAsync( GetOverTimeDetailReportParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _OverTimeBLL.GetOverTimeDetailReport( req.FirstNumber, req.MaxResult, req.CriteriaDTO, LoginDTO!); int total = Convert.ToInt32(await _OverTimeBLL.GetOverTimeDetailReport( -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); } } } }