using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using MMBLL.MMReports; using MMDAL.DTO.MMReports; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.MMReports { // Route matches the legacy GB4 MMReports.svc/MMPendingStatusReport endpoint exactly — // MWEBSERVICE -1399991846 is repointed at this route (see the MM migration script). public class GetMMPendingStatusReport : BaseReportEndpoint { private readonly IMMReportsBLL _bll; public GetMMPendingStatusReport(IMMReportsBLL bll) { _bll = bll; } public override void Configure() { Post("/MMReports/GetMMPendingStatusReport"); AllowAnonymous(); } public record GetMMPendingStatusReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] string BizTransactionClassId, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async IAsyncEnumerable ExecuteReportAsync( GetMMPendingStatusReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var (items, _) = await _bll.GetMMPendingStatusReport( 1, int.MaxValue, req.BizTransactionClassId, req.ReportCallingDTO.CriteriaDTO, login, ct).ConfigureAwait(false); foreach (var row in items) { ct.ThrowIfCancellationRequested(); yield return row; } } protected override async Task> ExecutePagedAsync( GetMMPendingStatusReportParameter req, LoginDTO login, CancellationToken ct) { try { var (items, total) = await _bll.GetMMPendingStatusReport( req.FirstNumber, req.MaxResult, req.BizTransactionClassId, req.ReportCallingDTO.CriteriaDTO, login, ct).ConfigureAwait(false); var response = await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( items, CacheKeyLevel.NOT_REQUIRED, login).ConfigureAwait(false); response.Total = total; return response; } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500).ConfigureAwait(false); } } } }