using FastEndpoints; using FrameworkBLL.AutoScheduler; using FrameworkDAL.DTO.AutoScheduler; using FrameworkSL.Endpoints.AutoScheduler; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.AutoScheduler { public class SaveAutoScheduler : BaseEndpoint> { private readonly IAutoSchedulerBLL _AutoSchedulerBLL; public SaveAutoScheduler(IAutoSchedulerBLL AutoSchedulerBLL) { _AutoSchedulerBLL = AutoSchedulerBLL; } public override void Configure() { Post("/AutoScheduler/SaveAutoScheduler"); AllowAnonymous(); } public record SaveAutoSchedulerParameters( [property: FromBody] AutoSchedulerDTO AutoSchedulerDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveAutoSchedulerParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _AutoSchedulerBLL.SaveAutoScheduler(req.AutoSchedulerDTO, 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 ); } } } }