using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using PayRollBLL.Job; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Job { // Full-DTO job list (JobDTO, not JobPicklistDTO) — mirrors // AccountsSL.EndPoints.CostCenter.GetCostCenterList's shape: a plain CriteriaDTO-filtered // List call, no FirstNumber/MaxResult paging like GetSelectListJob. // // The [FromBody] property must be literally named/typed ReportCallingDTO — see // GetCostCenterList.cs for the full rationale (BaseEndpoint.GetReportCallingDTOFromRequest // reflection lookup). public class GetJobList : BaseEndpoint> { private readonly IJobBLL _JobBLL; public GetJobList(IJobBLL jobBLL) { _JobBLL = jobBLL; } public override void Configure() { Post("/Job/GetJobList"); AllowAnonymous(); } public record GetJobListParameters( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override async Task> ExecuteAsync(GetJobListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _JobBLL.GetJobList(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); } } } }