Пример #1
0
        public ActionResult DisplayDBMovieDetails(int id)
        {
            System.Diagnostics.Debug.WriteLine("id: " + id);
            Movie movie = db.db.Movies.Where(m => m.ID == id).FirstOrDefault();
            HashSet <Models.Genre> genres = new HashSet <Models.Genre>();
            var genremovies = db.db.GenreMovies.ToList();

            if (genremovies.Any())
            {
                foreach (var genre in genremovies.Where(gm => gm.MovieID == id))
                {
                    genres.Add(db.db.Genres.Find(genre.GenreID));
                }
            }
            HashSet <Actor> actors      = new HashSet <Actor>();
            var             actormovies = db.db.ActorMovies.ToList();

            if (actormovies.Any())
            {
                foreach (var actor in actormovies.Where(am => am.MovieID == movie.ID))
                {
                    actors.Add(db.db.Actors.Find(actor.ActorID));
                }
            }

            MovieViewModel movieViewModel = new MovieViewModel
            {
                Movie      = movie,
                Genres     = genres.ToList(),
                Regisseur  = db.db.Regisseurs.Find(movie.RegisseurID),
                Actors     = actors.ToList(),
                MovieCover = db.GetMovieCover(movie.Title)
            };


            return(PartialView(movieViewModel));
        }