using AccountsBLL.Voucher; using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.Voucher { // Legacy GB4 route: Voucher.svc/BRS/Load/?FirstNumber={FirstNumber}&MaxResult={MaxResult} (POST, // CriteriaDTO body). BRSLoadFilterDTO (Bank/Date/Status-only) was the wrong shape — confirmed via // research that GB4 has no method actually consuming it; the real BRSLoad takes a CriteriaDTO // with ~19 dynamically-parsed filter fields, same pattern as GetSelectListBillAllocation. public class LoadBRS : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public LoadBRS(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Post("/Voucher/BRSLoad"); AllowAnonymous(); } public record LoadBRSParameters( [property: FromHeader] string Login, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(LoadBRSParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(LoadBRSParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VoucherBLL.LoadBRS(req.FirstNumber, req.MaxResult, req.CriteriaDTO, LoginDTO!); 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); } } } }