using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using PayRollBLL.GratuityGroup; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.GratuityGroup { // Full-DTO gratuity group list (GratuityGroupDTO, header fields only) — mirrors // AccountsSL.EndPoints.CostCenter.GetCostCenterList's shape: a plain CriteriaDTO-filtered // List call, no FirstNumber/MaxResult paging like GetSelectListGratuityGroup. // // The [FromBody] property must be literally named/typed ReportCallingDTO — see // GetCostCenterList's comment for why (BaseEndpoint.GetReportCallingDTOFromRequest looks it // up by that exact property name via reflection). public class GetGratuityGroupList : BaseEndpoint> { private readonly IGratuityGroupBLL _GratuityGroupBLL; public GetGratuityGroupList(IGratuityGroupBLL gratuityGroupBLL) { _GratuityGroupBLL = gratuityGroupBLL; } public override void Configure() { Post("/GratuityGroup/GetGratuityGroupList"); AllowAnonymous(); } public record GetGratuityGroupListParameters( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override async Task> ExecuteAsync( GetGratuityGroupListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _GratuityGroupBLL.GetGratuityGroupList(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); } } } }