private void btnEditMovie_Click(object sender, RoutedEventArgs e) { if (mvm.SelectedMovie != null) { AddEditMovieDialog cd = new AddEditMovieDialog(); cd.Title = "Redigér film"; cd.tbMovieTitle.Text = mvm.SelectedMovie.Title; cd.tbMovieGenre.Text = mvm.SelectedMovie.Genre; cd.tbMovieDuration.Text = mvm.SelectedMovie.Duration.ToString(); cd.tbMovieDirector.Text = mvm.SelectedMovie.Director; cd.dpMovieReleaseDate.SelectedDate = mvm.SelectedMovie.ReleaseDate; if ((bool)cd.ShowDialog()) { if (mvm.SelectedMovie.Title != cd.tbMovieTitle.Text || mvm.SelectedMovie.Genre != cd.tbMovieGenre.Text || mvm.SelectedMovie.Duration != cd.Minutes || mvm.SelectedMovie.Director != cd.tbMovieDirector.Text || mvm.SelectedMovie.ReleaseDate != cd.dpMovieReleaseDate.SelectedDate.Value) { mvm.UpdateMovie(mvm.SelectedMovie, cd.tbMovieTitle.Text, cd.tbMovieGenre.Text, cd.Minutes, cd.tbMovieDirector.Text, cd.dpMovieReleaseDate.SelectedDate.Value); } } } else { MessageBox.Show($"Ingen film er valgt. Vælg først en.", "Kan ikke redigere film", MessageBoxButton.OK); } }
private void btnAddMovie_Click(object sender, RoutedEventArgs e) { AddEditMovieDialog cd = new AddEditMovieDialog(); cd.Title = "Tilføj ny film"; if ((bool)cd.ShowDialog()) { try { mvm.AddMovie(cd.tbMovieTitle.Text, cd.tbMovieGenre.Text, cd.Minutes, cd.tbMovieDirector.Text, cd.dpMovieReleaseDate.SelectedDate.Value); } catch (NotImplementedException) { MessageBox.Show("Denne funktionalitet er endnu ikke implementeret!", "Kan ikke tilføje film", MessageBoxButton.OK); } catch (Exception) { MessageBox.Show($"Filmen {cd.tbMovieTitle} mm. eksisterer allerede. Prøv igen.", "Kan ikke tilføje film", MessageBoxButton.OK); } } }