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 onClick_Add(object sender, RoutedEventArgs e) { ShowRecord record = (ShowRecord)imdbShows.SelectedItem; ShowRecord newRecord = _repo.addFromImdb(record.imdbID); _show.Title = newRecord.Title; _show.Genre = newRecord.Genre; _show.IsFinished = false; _show.totalSeasons = newRecord.totalSeasons; _show.imdbID = newRecord.imdbID; MessageBoxResult result = MessageBox.Show("Are you sure you want to add the following show?" + "\nName of the show: " + _show.Title + "\nGenre of the show: " + _show.Genre + "\nTotal seasons in the show: " + newRecord.totalSeasons, "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { if (!_repo.addNewShow(_show)) { MessageBox.Show("The show with the same name already exists"); } else { var showEpisodes = _repo.getEpisodesInSeasons(_show.imdbID); var id = _repo.getIdOfExistingShow(_show.Title); _repo.addEpisodesToShow(id, showEpisodes); MessageBox.Show("The new show has been added. Please select your current episode"); ViewAllEpisodes eps = new ViewAllEpisodes(_show.Title); eps.episodes.ItemsSource = _repo.getAllEpisodesInShow(_show.Title); eps.Show(); } } }