using FastEndpoints; using EnablementBLL.ShowRule; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Threading; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace EnablementSL.Endpoints.Show.ShowRule { public class GetShowRule : BaseEndpoint> { private readonly IShowRuleBLL _showRuleBLL; public GetShowRule(IShowRuleBLL showRuleBLL) { _showRuleBLL = showRuleBLL; } public override void Configure() { Get("/Enablement/GetShowRule"); AllowAnonymous(); } public record GetShowRuleParameters( [property: FromHeader] string Login, [property: QueryParam] int ShowRuleId ); protected override async Task> ExecuteAsync( GetShowRuleParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _showRuleBLL.GetShowRuleAsync( req.ShowRuleId, loginDTO ); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.USER_LEVEL, loginDTO ); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.USER_LEVEL, loginDTO, ex.Message, 500 ); } } } }