public CreateMovieViewModel(Database database)
        {
            this._database = database;

            AddMovie = new SimpleCommand <object>((ignored) =>
            {
                database.AddMovie(new Movie(Title, ReleaseDate, Actor, Genre));
                RaiseFinished();
            }, (ignored) => !string.IsNullOrWhiteSpace(Title) &&
                                                  ReleaseDate != null &&
                                                  Actor != null &&
                                                  Genre != null);

            PropertyChanged += (sender, prop) => AddMovie.RaiseCanExecuteChanged();
        }
Beispiel #2
0
 public EditMovieViewModel(Movie movie, Database database)
 {
     this._database   = database;
     this.Movie       = movie;
     this.Title       = movie.Title;
     this.ReleaseDate = movie.ReleaseDate;
     this.Actor       = movie.Actor;
     this.Genre       = movie.Genre;
     EditMovie        = new SimpleCommand <object>((object ignored) =>
     {
         Movie.Edit(Title, ReleaseDate, Actor, Genre);
         RaiseFinished();
     }, (object ignored) => !string.IsNullOrWhiteSpace(Title) &&
                                                   ReleaseDate != null &&
                                                   Actor != null &&
                                                   Genre != null);
     PropertyChanged += (object sender, PropertyChangedEventArgs args) => EditMovie.RaiseCanExecuteChanged();
 }
Beispiel #3
0
        public MainWindowViewModel(Database database)
        {
            _database = database;

            AddActorClicked = new SimpleCommand <object>((object ignored) =>
            {
                State = new CreateActorViewModel(database);
            });
            AddGenreClicked = new SimpleCommand <object>((object ignored) =>
            {
                State = new CreateGenreViewModel(database);
            });
            AddMovieClicked = new SimpleCommand <object>((object ignored) =>
            {
                State = new CreateMovieViewModel(database);
            });
            EditActorClicked = new SimpleCommand <object>((object ignored) =>
            {
                if (SelectedActor == null)
                {
                    return;
                }
                State         = new EditActorViewModel(SelectedActor);
                SelectedActor = null;
            });
            EditGenreClicked = new SimpleCommand <object>((object ignored) =>
            {
                if (SelectedGenre == null)
                {
                    return;
                }
                State         = new EditGenreViewModel(SelectedGenre);
                SelectedGenre = null;
            });
            EditMovieClicked = new SimpleCommand <object>((object ignored) =>
            {
                if (SelectedMovie == null)
                {
                    return;
                }
                State         = new EditMovieViewModel(SelectedMovie, database);
                SelectedMovie = null;
            });
            RemoveActorClicked = new SimpleCommand <object>((object ignored) =>
            {
                if (SelectedActor == null)
                {
                    return;
                }
                _database.RemoveActor(SelectedActor);
                SelectedActor = null;
            });
            RemoveGenreClicked = new SimpleCommand <object>((object ignored) =>
            {
                if (SelectedGenre == null)
                {
                    return;
                }
                _database.RemoveGenre(SelectedGenre);
                SelectedGenre = null;
            });
            RemoveMovieClicked = new SimpleCommand <object>((object ignored) =>
            {
                if (SelectedMovie == null)
                {
                    return;
                }
                _database.RemoveMovie(SelectedMovie);
                SelectedMovie = null;
            });
        }