using AccountsBLL.AccountGroup; 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.AccountGroup { // Full-DTO account group list (AccountGroupDTO, not AccountGroupPicklistDTO) — mirrors // AccountsSL.EndPoints.Account.GetAccountList exactly: a plain CriteriaDTO-filtered List // call, no FirstNumber/MaxResult paging, no dynamic OrderBy (GB4's Criteria.svc/List/ // ?OBJECTCODE=ACCOUNTGROUP had both, but per explicit instruction this mirrors AccountList's // simpler shape instead of reintroducing GB4's generic/dynamic-sort mechanism). // // 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, which this is). A custom wrapper class here // makes that lookup return null and 400s with "Report export requires a ReportCallingDTO..." even // though this endpoint never runs the export path itself. ReportCallingDTO.CriteriaDTO already // matches the { "CriteriaDTO": { "SectionCriteriaList": [...] } } body reportviewer.dbservice.ts's // existing generic GB5 branch sends — so this satisfies BaseEndpoint's check with no FE change. public class GetAccountGroupList : BaseEndpoint> { private readonly IAccountGroupBLL _accountGroupBLL; public GetAccountGroupList(IAccountGroupBLL accountGroupBLL) { _accountGroupBLL = accountGroupBLL; } public override void Configure() { Post("/AccountGroup/GetAccountGroupList"); AllowAnonymous(); } public record GetAccountGroupListParameters( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override async Task> ExecuteAsync(GetAccountGroupListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _accountGroupBLL.GetAccountGroupList(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); } } } }