using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.InspectionParamSetEngine; using MMDAL.DTO.InspectionParamSetOverride; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.InspectionParamSetEngine { public class ResolveInspectionParameterSet : BaseEndpoint> { private readonly IInspectionParamSetEngineBLL _bll; public ResolveInspectionParameterSet(IInspectionParamSetEngineBLL bll) => _bll = bll; public override void Configure() { Post("/InspectionParamSetEngine/ResolveInspectionParameterSet"); AllowAnonymous(); } public record ResolveInspectionParameterSetParameters( [property: FromBody] InspectionParamSetResolveContextDTO InspectionParamSetResolveContextDTO, [property: FromHeader] string Login ); // Context-dependent (Party/Item/InspectionType) and must reflect the latest // override edits immediately — never cached. protected override string? GetCacheKey(ResolveInspectionParameterSetParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( ResolveInspectionParameterSetParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _bll.ResolveEffectiveParameterSetsAsync(req.InspectionParamSetResolveContextDTO, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponseEnumerable(result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }