public void InsertOrUpdateRule(int version, RuleDto rule) { _log.Info(m => m("Updating '{0}' rule", rule.RuleName)); using (var context = _contextFactory.Create(_repositoryName)) { using (var command = _commandFactory.CreateStoredProcedure("sp_InsertUpdateRule")) { command.AddParameter("ruleName", rule.RuleName); command.AddParameter("version", version); command.AddParameter("application", rule.Application); command.AddParameter("environment", rule.Environment); command.AddParameter("instance", rule.Instance); command.AddParameter("machine", rule.Machine); command.AddParameter("config", rule.ConfigurationData); context.ExecuteNonQuery(command); } using (var command = _commandFactory.CreateStoredProcedure("sp_DeleteRuleVariables")) { command.AddParameter("ruleName", rule.RuleName); command.AddParameter("version", version); context.ExecuteNonQuery(command); } if (rule.Variables != null && rule.Variables.Count > 0) { using (var command = _commandFactory.CreateStoredProcedure("sp_InsertRuleVariable")) { command.AddParameter("ruleName", rule.RuleName); command.AddParameter("version", version); var variableName = command.AddParameter("variableName", SqlDbType.NVarChar, ParameterDirection.Input); var variableValue = command.AddParameter("variableValue", SqlDbType.NVarChar, ParameterDirection.Input); foreach (var variable in rule.Variables) { variableName.Value = variable.VariableName; variableValue.Value = variable.SubstitutionValue; context.ExecuteNonQuery(command); } } } } }
private Task CreateRule(IOwinContext context, int version, RuleDto rule) { var clientCredentials = context.Get<IClientCredentials>("ClientCredentials"); _ruleData.AddRules(clientCredentials, version, new List<RuleDto> { rule }); return Json(context, new PostResponseDto { Success = true }); }
public void InsertOrUpdateRule(int version, RuleDto rule) { CheckForUpdate(); var ruleVersion = GetVersion(version, true); if (ruleVersion == null) return; ruleVersion.Rules.RemoveAll(r => string.Equals(r.RuleName, rule.RuleName, StringComparison.InvariantCultureIgnoreCase)); ruleVersion.Rules.Add(rule); SaveChanges(); }
public void InsertOrUpdateRule(int version, RuleDto rule) { var ruleVersion = _rules.FirstOrDefault(r => r.Version == version); if (ruleVersion == null) return; ruleVersion.Rules.RemoveAll(r => string.Equals(r.RuleName, rule.RuleName, StringComparison.InvariantCultureIgnoreCase)); ruleVersion.Rules.Add(rule); }
private Task UpdateRule(IOwinContext context, int version, string name, RuleDto rule) { var clientCredentials = context.Get<IClientCredentials>("ClientCredentials"); _ruleData.UpdateRule(clientCredentials, version, name, rule); return Json(context, new PostResponseDto { Success = true }); }