Exemplo n.º 1
0
        private void AddNewWord()
        {
            var word        = UserClientInputUtils.GetUserInputForNewWord();
            var translation = UserClientInputUtils.GetUserInputForNewWordTranslations();

            Word newWord = new Word()
            {
                Name        = word,
                Translation = translation
            };

            this.WordsCollection.Insert(newWord);
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        private void FindGivenWordTranslation()
        {
            var searchedWordName = UserClientInputUtils.GetUserInputSearchedWordName();

            var searchedWord = this.WordsCollection.AsQueryable()
                               .Where(w => w.Name == searchedWordName)
                               .FirstOrDefault();

            if (searchedWord != null)
            {
                Console.WriteLine("The word's {0} translation is : {1}", searchedWord.Name, searchedWord.Translation);
            }
            else
            {
                Console.WriteLine("There is no such word in the database. You can try and enter a new word.");
            }
        }