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/LoadOvertimeRecords/ (POST) — LoadOvertimeRecords(CriteriaDTO). // CriteriaDTO body only, no paging (matches GB4 SVC contract exactly). public class LoadOvertimeRecords : BaseEndpoint> { private readonly IOverTimeBLL _OverTimeBLL; public LoadOvertimeRecords(IOverTimeBLL OverTimeBLL) { _OverTimeBLL = OverTimeBLL; } public override void Configure() { Post("/OverTime/LoadOvertimeRecords"); AllowAnonymous(); } public record LoadOvertimeRecordsParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(LoadOvertimeRecordsParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( LoadOvertimeRecordsParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _OverTimeBLL.LoadOvertimeRecords(req.CriteriaDTO, loginDTO, ct); 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); } } } }