using AccountsBLL.Voucher; using AccountsDAL.DTO.Voucher; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.Voucher { public class AutoPendingBillAllocation : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public AutoPendingBillAllocation(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Post("/Voucher/AutoPendingBillAllocation"); AllowAnonymous(); } // Matches the real legacy call: POST ?Amount=100 with a BillAllocationFilterDTO-shaped // body ({ AccountId, DetailType, OuId, ... }) — confirmed against the actual live GB4 request. public record AutoPendingBillAllocationParameters( [property: FromHeader] string Login, [property: QueryParam] double Amount, [property: FromBody] BillAllocationFilterDTO BillAllocationFilterDTO ); protected override string? GetCacheKey(AutoPendingBillAllocationParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(AutoPendingBillAllocationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VoucherBLL.AutoPendingBillAllocation(req.Amount, req.BillAllocationFilterDTO, 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); } } } }