using FrameworkBLL.SystemJob; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using FrameworkDAL.DTO.SystemJob; using FrameworkDAL.Constant; using static FrameworkDAL.Constant.Constant; using FastEndpoints; namespace FrameworkSL.Endpoints.SystemJob { public class SaveSystemJob : BaseEndpoint> { private readonly ISystemJobBLL _SystemJobBLL; public SaveSystemJob(ISystemJobBLL SystemJobBLL) { _SystemJobBLL = SystemJobBLL; } public override void Configure() { Post("/SystemJob/SaveSystemJob"); AllowAnonymous(); } public record SaveSystemJobParameters( [property: FromHeader] string Login, [property: FromBody] SystemJobDTO SystemJobDTO ); protected override async Task> ExecuteAsync(SaveSystemJobParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _SystemJobBLL.SaveSystemJob(req.SystemJobDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }