private void button_Save(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Are these details correct?" + "\nName of the show: " + namebox.Text + "\nGenre of the show: " + genreBox.Text + "\nCurrent episode: " + Int32.Parse(currentEpBox.Text) + "\nCurrent season: " + Int32.Parse(currentSeasonBox.Text) + "\nTotal seasons: " + Int32.Parse(overallSeasonsBox.Text), "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { _show.Title = namebox.Text; _show.Genre = genreBox.Text; _show.CurrentEpisode = Int32.Parse(currentEpBox.Text); _show.CurrentSeason = Int32.Parse(currentSeasonBox.Text); _show.totalSeasons = Int32.Parse(overallSeasonsBox.Text); _show.IsFinished = false; if (!_repo.addNewShow(_show)) { MessageBox.Show("The show with the same name already exists"); } else { MessageBox.Show("The new show 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(); } } }