using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.SalesDB; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.SalesDB { // Route matches the legacy GB4 DutyTable.svc/SalesSummaryDashboard endpoint — // MWEBSERVICE -1399992787 is repointed at this route (see the MM migration script). public class GetSalesSummaryDashboard : BaseEndpoint> { private readonly ISalesDBBLL _SalesDBBLL; public GetSalesSummaryDashboard(ISalesDBBLL salesDBBLL) { _SalesDBBLL = salesDBBLL; } public override void Configure() { Post("/DutyTable/SalesSummaryDashboard"); AllowAnonymous(); } public record GetSalesSummaryDashboardParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(GetSalesSummaryDashboardParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(GetSalesSummaryDashboardParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var dashboard = await _SalesDBBLL.GetSalesSummaryDashboard(req.CriteriaDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(dashboard, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }