private void AdminCommand(string commandparameters) { string[] parameters = commandparameters.Split(' '); string command = parameters[0]; parameters[0] = parameters[0].ToLower(); Dictionary <string, Action> adminCommands = new Dictionary <string, Action>(); switch (parameters.Length) { case 1: adminCommands.Add(":q", () => _ui.Close()); adminCommands.Add(":quit", () => _ui.Close()); adminCommands.Add(":help", () => _ui.ShowHelp()); if (adminCommands.ContainsKey(command)) { adminCommands[command](); } else { _ui.DisplayAdminCommandNotFoundMessage(commandparameters); } break; case 2: int id = int.Parse(parameters[1]); adminCommands.Add(":active", () => SetProductActive(id, true)); adminCommands.Add(":deactive", () => SetProductActive(id, false)); adminCommands.Add(":crediton", () => SetProductCredit(id, true)); adminCommands.Add(":creditoff", () => SetProductCredit(id, false)); Product product = _stregsystem.GetProductByID(id); if (product != null) { if (adminCommands.ContainsKey(command)) { adminCommands[command](); } else { _ui.DisplayAdminCommandNotFoundMessage(commandparameters); } } else { _ui.DisplayProductNotFound(id.ToString()); } break; case 3: string userName = parameters[1]; int credit = int.Parse(parameters[2]); adminCommands.Add(":addcredits", () => InsertCashTransaction(userName, credit)); User user = _stregsystem.GetUserByUsername(userName); if (user != null) { if (adminCommands.ContainsKey(command)) { adminCommands[command](); } else { _ui.DisplayAdminCommandNotFoundMessage(commandparameters); } } else { _ui.DisplayUserNotFound(userName); } break; default: _ui.DisplayAdminCommandNotFoundMessage(commandparameters); break; } }