using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using QMSBLL.Matrix; using static GB5Shared.GB5Constant.Constant; namespace QMSSL.EndPoints.Matrix; public class GetSkippedSerials : BaseEndpoint> { private readonly IMatrixBLL _bll; public GetSkippedSerials(IMatrixBLL bll) => _bll = bll; public override void Configure() { Get("/Matrix/GetSkippedSerials"); AllowAnonymous(); Description(x => x .WithTags("Matrix") .WithSummary("Get Skipped Serials") .WithDescription("Lists serials previously deselected during a SaveSetSerialGenration call for " + "the given FG ItemId — their TLOT row exists (Status=0) so the number was never reissued, " + "but they were never actually used. Offered back here so a future generation run can let " + "the user manually reuse one instead of it sitting unused forever.")); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int ItemId); protected override string? GetCacheKey(Params req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetSkippedSerialsAsync(req.ItemId, login, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }