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 UpdateBillAllocation : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public UpdateBillAllocation(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Post("/Voucher/UpdateBillAllocation"); AllowAnonymous(); } public record UpdateBillAllocationParameters( [property: FromHeader] string Login, [property: FromBody] VoucherBillAllocationDTO VoucherBillAllocationDTO ); protected override string? GetCacheKey(UpdateBillAllocationParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(UpdateBillAllocationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VoucherBLL.UpdateBillAllocation(req.VoucherBillAllocationDTO, 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); } } } }