using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Scheduling; using MMDAL.DTO.Scheduling; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Scheduling { public class RescheduleHorizon : BaseEndpoint> { private readonly ISchedulingRunBLL _SchedulingRunBLL; public RescheduleHorizon(ISchedulingRunBLL schedulingRunBLL) { _SchedulingRunBLL = schedulingRunBLL; } public override void Configure() { Post("/Scheduling/RescheduleHorizon"); AllowAnonymous(); } public record RescheduleHorizonParameters( [property: FromHeader] string Login, [property: FromBody] SchedulingRunTriggerDTO TriggerDTO ); protected override string? GetCacheKey(RescheduleHorizonParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( RescheduleHorizonParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _SchedulingRunBLL.RescheduleAsync(req.TriggerDTO, 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); } } } }