private async Task InsertRule(RuleModel rule, string connectionString) { List <RuleModel> rules = new List <RuleModel>(); string userName = CommonDbUtilities.GetUsername(connectionString); rule.ModifiedBy = userName; rule.CreatedBy = userName; rule.RuleKey = GetRuleKey(rule, connectionString); rule.CreatedDate = DateTime.Now; rule.ModifiedDate = DateTime.Now; rules.Add(rule); await _ruleData.InsertRules(rules, connectionString); }
private void UpdateRule(RuleModel rule, string connectionString) { string userName = CommonDbUtilities.GetUsername(connectionString); rule.ModifiedBy = userName; string json = JsonConvert.SerializeObject(rule, Formatting.Indented); json = Common.SetJsonDataObjectDate(json, "ModifiedDate"); using (IDbConnection cnn = new SqlConnection(connectionString)) { var p = new DynamicParameters(); p.Add("@json", json); string sql = "dbo.spUpdateRules"; int recordsAffected = cnn.Execute(sql, p, commandType: CommandType.StoredProcedure); } }