public void AddInfo(int ruleId, string user) { using (var db = new SqliteContext()) { var info = db.Infos.SingleOrDefault(o => o.RuleId == ruleId && o.UserId == user); if (info == null) { info = new StatisticInfo(ruleId, user); db.Infos.Add(info); db.SaveChanges(); } info.Count++; db.Infos.Update(info); db.SaveChanges(); } }
public void AddRule(string chatType, string statisticWord, long chatId) { var rule = new StatisticRule(GetRuleIndex(), chatType, statisticWord, chatId); using (var db = new SqliteContext()) { db.Rules.Add(rule); db.SaveChanges(); } }