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 { // Legacy GB4 route: Voucher.svc/BRS/Update (POST, body = List). Each item carries its // own InstrumentId/InstrumentStatus/Date, so a single call can mix statuses across instruments. // This currently only ports GB4's status/date column flip ("Loop A") — bounce-voucher generation // ("Loop B", triggered by InstrumentStatus == 3/Bounce) is deferred; the cheque-bounce-specific // fields on BRSLoadDTO are accepted but not yet acted on. public class UpdateBRS : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public UpdateBRS(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Post("/Voucher/UpdateBRS"); AllowAnonymous(); } public record UpdateBRSParameters( [property: FromHeader] string Login, [property: FromBody] List BRSLoadDTOs ); protected override string? GetCacheKey(UpdateBRSParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(UpdateBRSParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VoucherBLL.UpdateBRS(req.BRSLoadDTOs, 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); } } } }