using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Periodic; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.Endpoints.Periodic { public class GetPeriodicList : BaseEndpoint> { private readonly IPeriodicBLL _PeriodicBLL; public GetPeriodicList(IPeriodicBLL PeriodicBLL) { _PeriodicBLL = PeriodicBLL; } public override void Configure() { Post("/Periodic/GetPeriodicList"); AllowAnonymous(); } // Body is a plain CriteriaDTO ({ "SectionCriteriaList": [...] }) — same generic // criteria shape GetPayGroupList/GetCostCenterList/etc. already use. Only // PayPeriodId/Applicable/OUId/PayGroupId/PayConfigurationId/DAGroupId/EmployeeId are // recognized (see PeriodicDAL.ExtractPeriodicFilter); a field only filters when it's // actually present in AttributesCriteriaList. public record GetPeriodicListParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override async Task> ExecuteAsync( GetPeriodicListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _PeriodicBLL.GetPeriodicList(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); } } } }