using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; using FrameworkBLL.SystemJob; namespace FrameworkSL.Endpoints.SystemJob { // Lets the frontend disable the "Job" button with an honest message instead of accepting // a submission the executor can only ever fail on (no MWEBSERVICE route configured). public class GetJobEligibility : BaseEndpoint> { private readonly ISystemJobBLL _SystemJobBLL; public GetJobEligibility(ISystemJobBLL ISystemJobBLL) { _SystemJobBLL = ISystemJobBLL; } public override void Configure() { Get("/SystemJob/GetJobEligibility"); AllowAnonymous(); } public record GetJobEligibilityParameters( [property: FromHeader] string Login, [property: QueryParam] int WebServiceId ); protected override string? GetCacheKey(GetJobEligibilityParameters Parameters, LoginDTO LoginDTO) { return null; // routing config can change without a new deploy — never cache this } protected override async Task> ExecuteAsync(GetJobEligibilityParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _SystemJobBLL.CheckJobEligibility(req.WebServiceId, 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); } } } }