Ejemplo n.º 1
0
        public UpdateViewModelTwo()
        {
            CommandUpdate   = new RelayCommand <object>(CommandUpdateExecute, CommandUpdateCanExecute);
            CommandAddActor = new RelayCommand(CommandAddActorExecute, CommandAddActorCanExecute);
            CommandReturn   = new RelayCommand <Page>(CommandReturnExecute);
            Messenger.Default.Register <MovieNET.User>(this, (User_co) =>
            {
                user_co = User_co;
            });
            Messenger.Default.Register <int>(this, (ID_movie) =>
            {
                id_movie      = ID_movie;
                selectedMovie = serviceClient.SelectOneMovie(id_movie);
                if (selectedMovie != null)
                {
                    SelectedMovieType = serviceClient.SelectOneMovieType(selectedMovie.Id_type);
                    SelectedDirector  = serviceClient.SelectOneDirector(selectedMovie.Id_director);
                    SelectedImage     = serviceClient.SelectOneImage(selectedMovie.Id_image);
                    ListActorMovie    = serviceClient.SelectActorByMovie(selectedMovie.Id_movie);

                    MovieTitle        = selectedMovie.Title;
                    MovieSynopsys     = selectedMovie.Synopsis;
                    MovieDurationHour = selectedMovie.Duration.Hours.ToString();
                    MovieDurationMin  = selectedMovie.Duration.Minutes.ToString();
                    MovieDurationSec  = selectedMovie.Duration.Seconds.ToString();
                    id_director       = SelectedDirector.Id_director;
                    id_movitype       = SelectedMovieType.Id_type;
                    Image             = SelectedImage.URL;
                    listMovieType     = serviceClient.SelectAllMovieType();
                    listMovieType.Add(new MovieNET.MovieType()
                    {
                        Id_type = 0, Type = "Autre"
                    });
                    listDirector = serviceClient.SelectAllDirector();
                    ListDirector.Add(new MovieNET.Director()
                    {
                        Id_director = 0, Firstname = "Autre"
                    });
                    listActor = serviceClient.SelectAllActor();
                    for (int i = 0; i < listMovieType.Count; i++)
                    {
                        if (listMovieType[i].Id_type == SelectedMovieType.Id_type)
                        {
                            MovieTypeIndex = i;
                        }
                    }
                    for (int i = 0; i < listDirector.Count; i++)
                    {
                        if (listDirector[i].Id_director == SelectedDirector.Id_director)
                        {
                            DirectorIndex = i;
                        }
                    }
                }
            });
        }
Ejemplo n.º 2
0
        public FilmViewModel()
        {
            CommandAddComment = new RelayCommand(CommandAddCommentExecute);
            CommandReturn     = new RelayCommand <Page>(CommandReturnExecute);
            Messenger.Default.Register <MovieNET.User>(this, (user_co) =>
            {
                User_co = user_co;
            });

            Messenger.Default.Register <int>(this, (ID_movie) =>
            {
                id_movie      = ID_movie;
                MovieSelected = serviceClient.SelectOneMovie(id_movie);
                if (MovieSelected != null)
                {
                    MovieType          = serviceClient.SelectOneMovieType(MovieSelected.Id_type);
                    MovieDirector      = serviceClient.SelectOneDirector(MovieSelected.Id_director);
                    MovieImage         = serviceClient.SelectOneImage(MovieSelected.Id_image);
                    MovieTitle         = MovieSelected.Title;
                    MovieSynopsis      = MovieSelected.Synopsis;
                    MovieDurationHours = MovieSelected.Duration.Hours;
                    MovieDurationMin   = MovieSelected.Duration.Minutes;
                    MovieDurationSec   = MovieSelected.Duration.Seconds;
                    ListActor          = serviceClient.SelectActorByMovie(id_movie);
                    ListComment        = serviceClient.SelectCommentByMovie(id_movie);
                    rating             = serviceClient.SelectRating(id_movie);

                    Title     = MovieTitle;
                    Synopsis  = MovieSynopsis;
                    Image     = MovieImage.URL;
                    Director  = MovieDirector.Firstname;
                    LDirector = MovieDirector.Lastname;
                    Type      = MovieType.Type;
                    Note      = rating;
                }
            });
        }