using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.SignalR.Protocol; using MMBLL.MMReports; using MMDAL.DTO.MMHead; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.MMReports { public class GetMMHeadRegister : BaseReportEndpoint { private readonly IMMReportsBLL _bll; public GetMMHeadRegister(IMMReportsBLL bll) { _bll = bll; } public override void Configure() { Post("/MMReports/GetMMHeadRegister"); AllowAnonymous(); } public record GetMMHeadRegisterParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int OrderByType, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); // Export path — streams ALL rows; paging params are ignored protected override IAsyncEnumerable ExecuteReportAsync( GetMMHeadRegisterParameter req, LoginDTO login, CancellationToken ct) => _bll.MMHeadRegister(req.OrderByType, req.FirstNumber, req.MaxResult, req.ReportCallingDTO.CriteriaDTO!, login, ct); // UI table path — paged via FirstNumber / MaxResult protected override async Task> ExecutePagedAsync( GetMMHeadRegisterParameter req, LoginDTO login, CancellationToken ct) { var result = await _bll.MMHeadRegister( req.OrderByType, req.FirstNumber, req.MaxResult, req.ReportCallingDTO.CriteriaDTO!, login, ct) .ToListAsync(ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } } }