using FastEndpoints; using FrameworkBLL.ReportHeaderMgmt; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ReportHeader { public class GetReportHeaderPaged : BaseEndpoint> { private readonly IReportHeaderBLL _bll; public GetReportHeaderPaged(IReportHeaderBLL bll) => _bll = bll; public override void Configure() { Get("/ReportHeader/GetReportHeaderPaged"); AllowAnonymous(); } public record GetReportHeaderPagedParameters( [property: FromHeader] string Login, [property: QueryParam] int Offset, [property: QueryParam] int PageSize ); protected override string? GetCacheKey(GetReportHeaderPagedParameters req, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync( GetReportHeaderPagedParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _bll.GetReportHeaderPaged(req.Offset, req.PageSize, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }