using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using TMSBLL.Reports.ComplianceCoverageRegister; using TMSDAL.DTO.Reports; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.Reports { public class GetTrainingComplianceCoverageRegister : BaseReportEndpoint { private readonly IComplianceCoverageRegisterBLL _bll; public GetTrainingComplianceCoverageRegister(IComplianceCoverageRegisterBLL bll) { _bll = bll; } public override void Configure() { Post("/TMSReports/GetTrainingComplianceCoverageRegister"); AllowAnonymous(); } public record GetTrainingComplianceCoverageRegisterParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: QueryParam] int MenuId ); protected override IAsyncEnumerable ExecuteReportAsync( GetTrainingComplianceCoverageRegisterParameter req, LoginDTO login, CancellationToken ct) => _bll.GetComplianceCoverageRegisterStream( req.FirstNumber, req.MaxResult, req.ReportCallingDTO?.CriteriaDTO, req.MenuId, login, ct); protected override async Task> ExecutePagedAsync( GetTrainingComplianceCoverageRegisterParameter req, LoginDTO login, CancellationToken ct) { var result = await _bll.GetComplianceCoverageRegister( req.FirstNumber, req.MaxResult, req.ReportCallingDTO?.CriteriaDTO, req.MenuId, login, ct).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } } }