void AddNewTranslation() { if (SelectedOriginalLanguage != null && SelectedTranslationLanguage != null && SelectedOriginalWord != null && TranslationWord != null && TranslationWord != "") { Word lastWord = tradicIterator.GetWords().Last(); Word translation = new Word { Id = lastWord.Id + 1, Text = TranslationWord, LanguageId = SelectedTranslationLanguage.Id, TranslationId = SelectedOriginalWord.TranslationId }; tradicIterator.AddEntity(translation); Words.Add(translation); TranslationWords.Add(translation); TranslationWord = ""; } else if (SelectedOriginalLanguage == null) { MessageBox.Show("You must select original language", "Language warning", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (SelectedTranslationLanguage == null) { MessageBox.Show("You must select translation language", "Language warning", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (SelectedOriginalWord == null) { MessageBox.Show("You must select original word", "Selection warning", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (TranslationWord == null || TranslationWord == "") { MessageBox.Show("You must enter translation", "Translation warning", MessageBoxButton.OK, MessageBoxImage.Warning); } }
void AddNewWord() { if ((OriginalWordText != null && OriginalWordText != "") && (TranslationWordText != null && TranslationWordText != "") && (SelectedOriginalLanguage != null && SelectedTranslationLanguage != null)) { dataAccess.AddEntity(new Translation()); Translation translation = dataAccess.GetTranslations().Last(); dataAccess.AddEntity(new Word { Text = OriginalWordText, LanguageId = SelectedOriginalLanguage.Id, TranslationId = translation.Id }); dataAccess.AddEntity(new Description { Text = OriginalWordDescription, WordId = dataAccess.GetWords().Last().Id }); dataAccess.AddEntity(new Word { Text = TranslationWordText, LanguageId = SelectedTranslationLanguage.Id, TranslationId = translation.Id }); dataAccess.AddEntity(new Description { Text = TranslationWordDescription, WordId = dataAccess.GetWords().Last().Id }); OriginalWordText = ""; TranslationWordText = ""; OriginalWordDescription = ""; TranslationWordDescription = ""; } else if (OriginalWordText == "" || OriginalWordText == null) { MessageBox.Show("You must enter original word", "Enter warning", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (TranslationWordText == "" || TranslationWordText == null) { MessageBox.Show("You mus enter translation word", "Enter warning", MessageBoxButton.OK, MessageBoxImage.Warning); } }