using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using PayRollBLL.ShiftPattern; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.ShiftPattern { // Full-DTO shift pattern list (ShiftPatternDTO, not ShiftPatternPicklistDTO) — mirrors // AccountsSL.EndPoints.CostCenter.GetCostCenterList's shape: a plain CriteriaDTO-filtered // List call, header fields only (no days/detail hierarchy embedded), no FirstNumber/MaxResult // paging like GetSelectListShiftPattern. // // The [FromBody] property must be literally named/typed ReportCallingDTO — see // GetCostCenterList.cs for the full rationale (BaseEndpoint.GetReportCallingDTOFromRequest // finds it via reflection on that exact property name). public class GetShiftPatternList : BaseEndpoint> { private readonly IShiftPatternBLL _ShiftPatternBLL; public GetShiftPatternList(IShiftPatternBLL shiftPatternBLL) { _ShiftPatternBLL = shiftPatternBLL; } public override void Configure() { Post("/ShiftPattern/GetShiftPatternList"); AllowAnonymous(); } public record GetShiftPatternListParameters( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override async Task> ExecuteAsync( GetShiftPatternListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _ShiftPatternBLL.GetShiftPatternList(req.ReportCallingDTO.CriteriaDTO!, loginDTO!); 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); } } } }