public static void DeleteBlackWord(string typeStr, string word) { BlackWordType type; if (!BlackWordType.TryParse(typeStr, true, out type)) { return; } var wordStruct = Words.FirstOrDefault(wordS => wordS.Type == type && word.Contains(wordS.Word)); if (string.IsNullOrEmpty(wordStruct.Word)) { return; } Words.Remove(wordStruct); using (var adapter = Azure.GetDatabaseManager().GetQueryReactor()) { adapter.SetQuery("DELETE FROM server_blackwords WHERE word = @word AND type = @type"); adapter.AddParameter("word", word); adapter.AddParameter("type", typeStr); adapter.RunQuery(); } }
public static void AddBlackWord(string typeStr, string word) { BlackWordType type; if (!BlackWordType.TryParse(typeStr, true, out type)) { return; } if (Words.Any(wordStruct => wordStruct.Type == type && word.Contains(wordStruct.Word))) { return; } using (var adapter = Azure.GetDatabaseManager().GetQueryReactor()) { adapter.SetQuery("INSERT INTO server_blackwords VALUES (null, @word, @type)"); adapter.AddParameter("word", word); adapter.AddParameter("type", typeStr); adapter.RunQuery(); } AddPrivateBlackWord(typeStr, word); }