using System; using System.Threading; using System.Threading.Tasks; using FastEndpoints; using FrameworkBLL.SystemJob; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.SystemJob { public class CloneSystemJob : BaseEndpoint> { private readonly ISystemJobBLL _SystemJobBLL; public CloneSystemJob(ISystemJobBLL systemJobBLL) { _SystemJobBLL = systemJobBLL; } public override void Configure() { Post("/SystemJob/CloneSystemJob"); AllowAnonymous(); } public record CloneSystemJobParameters( [property: FromHeader] string Login, [property: QueryParam] int SysJobId ); protected override async Task> ExecuteAsync(CloneSystemJobParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _SystemJobBLL.CloneSystemJob(req.SysJobId, 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); } } } }