Ejemplo n.º 1
0
 private void SaveMovieButton_Click(object sender, RoutedEventArgs e)
 {
     if (DirectorTextBox.Text != "" && MovieTitleTextBox.Text != "")
     {
         if (_movieController.Selected == null)
         {
             Movie newMovie = new Movie()
             {
                 Director = DirectorTextBox.Text,
                 Title    = MovieTitleTextBox.Text,
                 File     = _newFile
             };
             _movieController.AddMedia(newMovie);
         }
         else
         {
             Movie selectedMovie = (Movie)_movieController.Selected;
             selectedMovie.Director = DirectorTextBox.Text;
             selectedMovie.Title    = MovieTitleTextBox.Text;
             if (selectedMovie.File == null)
             {
                 selectedMovie.File = _newFile;
             }
             else if (selectedMovie.File != _newFile && _newFile != null)
             {
                 selectedMovie.File = _newFile;
             }
             _movieController.ChangeSelected(_movieController.Selected);
             movieListBox.Items.Refresh();
         }
         ClearSelection();
     }
     else
     {
         MessageBox.Show("Please fill in all the fields!");
     }
 }