using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using MMBLL.SalesDB; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.SalesDB; // ReportCallingDTO-accepting wrapper over GetSalesSummaryDashboard (Sales Overview Dashboard, // Phase 1). The dashboard-embed call chain (GetMenuReport/picklist -> Framework.ReportMenu.Get) // always POSTs a ReportCallingDTO{CriteriaDTO, MenuId} envelope; the existing endpoint takes // [FromBody] CriteriaDTO directly and would silently bind to a default/empty instance against // that envelope shape -- same class of wire-shape mismatch as the Compliance/BRS dashboard // wrappers (PostFilingStatusSummaryForDashboard, LoadBRSForDrilldown). The underlying BLL/DAL // logic is unchanged; this is presentation wiring only. public class PostSalesSummaryDashboard : BaseEndpoint> { private readonly ISalesDBBLL _bll; public PostSalesSummaryDashboard(ISalesDBBLL bll) => _bll = bll; public override void Configure() { Post("/DutyTable/SalesSummaryDashboardForDashboard"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override string? GetCacheKey(Params req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetSalesSummaryDashboard(req.ReportCallingDTO.CriteriaDTO, login, ct).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }