private void save_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Are the details correct?" + "\nTitle: " + titlebox.Text + "\nSeason: " + Int32.Parse(seasonBox.Text) + "\nEpisode: " + Int32.Parse(episodeBox.Text), "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { var episodes = new List <EpisodeRecord>() { new EpisodeRecord { Title = titlebox.Text, Season = Int32.Parse(seasonBox.Text), Episode = Int32.Parse(episodeBox.Text), ShowId = Int32.Parse(idElem.Text) } }; if (_repo.checkIfEpisodeAlreadyExists(episodes[0])) { MessageBox.Show("Episode with the same name already exists for this show"); } else { _repo.addEpisodesToShow(Int32.Parse(idElem.Text), episodes); MessageBox.Show("The new episode has been added"); this.Close(); } } }
private void save_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Are the new details correct?" + "\nTitle: " + titlebox.Text + "\nSeason: " + Int32.Parse(seasonBox.Text) + "\nEpisode: " + Int32.Parse(episodeBox.Text), " Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { _record.Title = titlebox.Text; _record.Season = Int32.Parse(seasonBox.Text); _record.Episode = Int32.Parse(episodeBox.Text); _record.ShowId = _repo.findEpisodesShowId(_record.Title); if (_record.Title == _oldTitle) { _repo.editEpisode(_record, _oldTitle); this.Close(); } else if (!_repo.checkIfEpisodeAlreadyExists(_record)) { _repo.editEpisode(_record, _oldTitle); this.Close(); } else { MessageBox.Show("The episode with the same name already exists for this show"); titlebox.Text = _oldTitle; } } }