private void ValidateAndHandleEnteredWord()
        {
            WordPair currentWordPair = _unknownWords.First(unknownWord => unknownWord.Id == _currentUnknownWordPairId);

            if (!SecondLanguageWordTextBox.ReadOnly)
            {
                bool isEqual = _wordsService.CheckIfWordsMatches(SecondLanguageWordTextBox.Text, currentWordPair.SecondLanguageWord);
                if (isEqual)
                {
                    HandleCorrectlyEnteredWord();
                }
                else
                {
                    HandleIncorrectlyEnteredWord(SecondLanguageWordTextBox, currentWordPair.SecondLanguageWord);
                }
            }
            else if (!FirstLanguageWordTextBox.ReadOnly)
            {
                bool isEqual = _wordsService.CheckIfWordsMatches(FirstLanguageWordTextBox.Text, currentWordPair.FirstLanguageWord);
                if (isEqual)
                {
                    HandleCorrectlyEnteredWord();
                }
                else
                {
                    HandleIncorrectlyEnteredWord(FirstLanguageWordTextBox, currentWordPair.FirstLanguageWord);
                }
            }
        }
Example #2
0
        private DuplicateWord WordPairAlreadyExits(IEnumerable <WordPairForDataGridView> wordsListExcludingCurrentlyEditingWord,
                                                   string firstLanguageWord, string secondLanguageWord)
        {
            var duplicateWord = new DuplicateWord
            {
                WordAlreadyExist = false
            };

            foreach (var word in wordsListExcludingCurrentlyEditingWord)
            {
                bool firstLanguageWordAlreadyExist  = _wordsService.CheckIfWordsMatches(word.FirstLanguageWord, firstLanguageWord);
                bool secondLanguageWordAlreadyExist = _wordsService.CheckIfWordsMatches(word.SecondLanguageWord, secondLanguageWord);

                if (firstLanguageWordAlreadyExist || secondLanguageWordAlreadyExist)
                {
                    duplicateWord.WordAlreadyExist = true;

                    duplicateWord.DuplicateWordValue = firstLanguageWordAlreadyExist ? firstLanguageWord : secondLanguageWord;

                    break;
                }
            }

            return(duplicateWord);
        }