private static void ProcessUserInputOption(string userInput, CommandCreator commandCreator, MongoCollection<Word> wordsCollection) { if (userInput.ToLower() == ExitCommandToLower) { ConsoleUtils.PrintGoodbyeMessage(); Environment.Exit(0); } if (UserClientInputUtils.IsUserInputCommandNumberValid(userInput)) { var command = commandCreator.CreateCommand(userInput, wordsCollection); command.Execute(); } }
static void Main() { var client = new MongoClient(ConnectionStringUrl); var server = client.GetServer(); var database = server.GetDatabase(DatabaseName); var wordsCollection = database.GetCollection<Word>(WordsCollectionName); var commandCreator = new CommandCreator(); ConsoleUtils.PrintHelloMessage(); while (true) { ConsoleUtils.PrintMenuOptions(); ConsoleUtils.PrintEnterMessageForInput(); var userInput = Console.ReadLine(); ProcessUserInputOption(userInput, commandCreator, wordsCollection); } }