using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.MMHead; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.MMHead { // Ported from GB4's GET /mms/MMHead.svc/Voucher/Forming/From/MMHead/ProcedureBased/?DocumentId= public class VoucherFormingFromMMHeadProcedureBased : BaseEndpoint { private readonly IMMHeadBLL _MMHeadBLL; public VoucherFormingFromMMHeadProcedureBased(IMMHeadBLL MMHeadBLL) { _MMHeadBLL = MMHeadBLL; } public override void Configure() { Get("/MMHead/VoucherFormingFromMMHeadProcedureBased"); AllowAnonymous(); } public record VoucherFormingFromMMHeadProcedureBasedParameters( [property: QueryParam] int DocumentId, [property: FromHeader] string Login ); // Never cached — this forms a fresh accounting voucher from live document data every call. protected override string? GetCacheKey(VoucherFormingFromMMHeadProcedureBasedParameters parameters, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(VoucherFormingFromMMHeadProcedureBasedParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _MMHeadBLL.VoucherFormingFromMMHeadProcedureBased(parameters.DocumentId, loginDTO!, ct); 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); } } } }