using FastEndpoints; using FrameworkBLL.SysJobRun; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; using System; using System.Threading; using System.Threading.Tasks; namespace FrameworkSL.Endpoints.SysJobRun { public class DeleteSysJobRun : BaseEndpoint> { private readonly ISysJobRunBLL _sysJobRunBLL; public DeleteSysJobRun(ISysJobRunBLL sysJobRunBLL) { _sysJobRunBLL = sysJobRunBLL; } public override void Configure() { Delete("/SysJobRun/DeleteSysJobRun"); AllowAnonymous(); } public record DeleteSysJobRunParameters( [property: FromHeader] string Login, [property: QueryParam] int SysJobRunId ); protected override async Task> ExecuteAsync(DeleteSysJobRunParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _sysJobRunBLL.DeleteSysJobRun(req.SysJobRunId, 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 ); } } } }