public IActionResult Post(string toggleName, bool toggleValue, string expression) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _toggleClientParser.Input = expression; if (!expression.IsNull() && !_toggleClientParser.IsValid()) { _log.LogError($"{Resources.InvalidExpressionFormatError}: {expression}"); return(this.NotAllowed(Resources.InvalidExpressionFormatError)); } var createCmd = new CreateToggle(toggleName, toggleValue); _commandHandler.Execute(createCmd); var clientPermissions = _toggleClientParser.Extract(); var whitelist = clientPermissions.Whitelist; var customValues = clientPermissions.CustomValues; if (whitelist.Any()) { var whitelistCmd = new AddToWhitelist(toggleName, whitelist); _commandHandler.Execute(whitelistCmd); } if (customValues.Any()) { var customValuesCmd = new AddToCustomValues(toggleName, customValues); _commandHandler.Execute(customValuesCmd); } return(Ok()); } catch (Exception e) { _log.LogError($"{Resources.InternalErrorMessage}:{e.Message}"); return(this.InternalServerError()); } }
private void btnAddWhitelist_Click(object sender, EventArgs e) => AddToWhitelist?.Invoke(this, EventArgs.Empty);