using AccountsBLL.CostCategory; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.CostCategory { // Full-DTO cost category list (CostCategoryDTO, not CostCategoryPicklistDTO) — mirrors // AccountSL.Endpoints.Account.GetAccountList's shape: a plain CriteriaDTO-filtered List call, // no FirstNumber/MaxResult paging like GetSelectListCostCategory. // // The [FromBody] property must be literally named/typed ReportCallingDTO, not a custom wrapper — // BaseEndpoint.GetReportCallingDTOFromRequest finds it via reflection on that exact property name // whenever the client sends an "H-ReportFormat"/"ReportFormat" header (which the frontend does // unconditionally for any MenuType=="Reports" menu). A custom wrapper class here makes that // lookup return null and 400s even though this endpoint never runs the export path itself. public class GetCostCategoryList : BaseEndpoint> { private readonly ICostCategoryBLL _costCategoryBLL; public GetCostCategoryList(ICostCategoryBLL costCategoryBLL) { _costCategoryBLL = costCategoryBLL; } public override void Configure() { Post("/CostCategory/GetCostCategoryList"); AllowAnonymous(); } public record GetCostCategoryListParameters( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override async Task> ExecuteAsync(GetCostCategoryListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _costCategoryBLL.GetCostCategoryList(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); } } } }