using EnablementBLL.ShowRule; using EnablementDAL.DTO; using EnablementSL.Parameters.ShowRule; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace EnablementSL.Endpoints.ShowRule; public class SaveShowRule : BaseEndpoint> { private readonly IShowRuleBLL _showRuleBLL; public SaveShowRule(IShowRuleBLL showRuleBLL) { _showRuleBLL = showRuleBLL; } public override void Configure() { Post("/Enablement/SaveShowRule"); AllowAnonymous(); } public record SaveShowRuleParameters( [property: FromHeader] string Login, [property: FromBody] ShowRuleDTO ShowRuleDTO ); protected override async Task> ExecuteAsync( SaveShowRuleParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _showRuleBLL.SaveShowRuleAsync(req.ShowRuleDTO, loginDTO, ct); 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); } } }