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 GetEventRule : BaseEndpoint> { private readonly IEventRuleBLL _bll; public GetEventRule(IEventRuleBLL bll) => _bll = bll; public override void Configure() { Get("/EventRule/GetEventRule"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int ActionId ); protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetEventRuleAsync(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); } } } }