using FastEndpoints; using FrameworkBLL.EventRule; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Threading; using System.Threading.Tasks; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.EventRule { public class DeleteEventRule : BaseEndpoint> { private readonly IEventRuleBLL _bll; public DeleteEventRule(IEventRuleBLL bll) => _bll = bll; public override void Configure() { Delete("/EventRule/DeleteEventRule"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int ActionId ); protected override string? GetCacheKey(Params req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.DeleteEventRuleAsync(req.ActionId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.UserLevel, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, login, ex.Message, 500); } } } }