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/MMRegisterItemWiseReport — MWEBSERVICE -1399991810. public class GetMMRegisterItemWiseReport : BaseReportEndpoint { private readonly IMMReportsBLL _bll; public GetMMRegisterItemWiseReport(IMMReportsBLL bll) { _bll = bll; } public override void Configure() { Post("/MMReports/GetMMRegisterItemWiseReport"); AllowAnonymous(); } public record GetMMRegisterItemWiseReportParameter( [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( GetMMRegisterItemWiseReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var (items, _) = await _bll.GetMMRegisterItemWiseReport( 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( GetMMRegisterItemWiseReportParameter req, LoginDTO login, CancellationToken ct) { try { var (items, total) = await _bll.GetMMRegisterItemWiseReport( 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); } } } }