public static CreateTagResult AddTag(string tagName, string tagText) { if (Tags.Count(x => x.Name.ToLower().Equals(tagName.ToLower())) >= 1) { return CreateTagResult.NameAlreadyUsed; } // var chatTag = new ChatTag { Name = tagName, Text = tagText, }; Tags.Add(chatTag); using (var db = new CommandsDB()) { db.Insert(chatTag); } //Similar to Begin invoke, this will execute the following task on the UI scheduler thread. var task = new Task(() => CommandsController.RefreshCustomTagsGrid()); task.Start(CommandsController.Scheduler); EventManager.LogEvent("CommandManager", tagName + " has been added to tags.", EventManager.GreenTextStyle); return CreateTagResult.Success; }
public static CreateCommandResult CreateCommand(string cmdName, string cmdText, string cmdLevel, int cmdTimer) { if(cmdName == null || cmdText == null) return CreateCommandResult.UnexpectedError; if (Commands.Count(x => x.Name != null && x.Name.ToLower().Equals(cmdName.ToLower())) >= 1) { return CreateCommandResult.NameAlreadyUsed; } var chatCommand = new ChatCommand { Name = cmdName, Text = cmdText, Level = (UserType)UserTypeStringToInt(cmdLevel), Timer = cmdTimer }; lock (Commands) { Commands.Add(chatCommand); } using (var db = new CommandsDB()) { db.Insert(chatCommand); } //Similar to Begin invoke, this will execute the following task on the UI scheduler thread. var task = new Task(() => CommandsController.RefreshCustomCommandsGrid()); task.Start(CommandsController.Scheduler); EventManager.LogEvent("CommandManager", cmdName + " has been added to commands.", EventManager.GreenTextStyle); return CreateCommandResult.Success; }