using AccountsBLL.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 { // Faithful port of GB4 Voucher.svc's ReAccountPostFast — full delete + rebuild + recompute // of TACCOUNTPOST for the caller's current OU, scoped by PeriodId/AccountId. public class ReAccountPost : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public ReAccountPost(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Get("/Voucher/ReAccountPost"); AllowAnonymous(); } public record ReAccountPostParameters( [property: FromHeader] string Login, [property: QueryParam] int PeriodId, [property: QueryParam] int AccountId ); protected override string? GetCacheKey(ReAccountPostParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(ReAccountPostParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VoucherBLL.ReAccountPostFast(req.PeriodId, req.AccountId, 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); } } } }