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 legacy MMReports.svc/MMRegisterPartyWiseSummaryReport — MWEBSERVICE -1399991844. // Type: 0 = active register summary, 1 = pending-allocation-based summary (matches legacy toggle). public class GetMMRegisterPartyWiseSummaryReport : BaseReportEndpoint { private readonly IMMReportsBLL _bll; public GetMMRegisterPartyWiseSummaryReport(IMMReportsBLL bll) { _bll = bll; } public override void Configure() { Post("/MMReports/GetMMRegisterPartyWiseSummaryReport"); AllowAnonymous(); } public record GetMMRegisterPartyWiseSummaryReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] string BizTransactionClassId, [property: QueryParam] int Type, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async IAsyncEnumerable ExecuteReportAsync( GetMMRegisterPartyWiseSummaryReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var (items, _) = await _bll.GetMMRegisterPartyWiseSummaryReport( 1, int.MaxValue, req.BizTransactionClassId, req.Type, req.ReportCallingDTO.CriteriaDTO, login, ct).ConfigureAwait(false); foreach (var row in items) { ct.ThrowIfCancellationRequested(); yield return row; } } protected override async Task> ExecutePagedAsync( GetMMRegisterPartyWiseSummaryReportParameter req, LoginDTO login, CancellationToken ct) { try { var (items, total) = await _bll.GetMMRegisterPartyWiseSummaryReport( req.FirstNumber, req.MaxResult, req.BizTransactionClassId, req.Type, 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); } } } }