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/GetVoucherTDS/ (POST, CriteriaDTO body). GB4 filters dynamically // by AccountId/VoucherTDSId (never by VoucherId) and always excludes already-allotted TDS entries // (AllotedVoucherLine.Id = -1) — GB5's TVOUCHERTDS table has no ALLOTEDVOUCHERLINEID column, so // that allotment filter cannot be replicated here. public class GetVoucherTDS : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public GetVoucherTDS(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Post("/Voucher/GetVoucherTDS"); AllowAnonymous(); } public record GetVoucherTDSParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(GetVoucherTDSParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(GetVoucherTDSParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VoucherBLL.GetVoucherTDS(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); } } } }