Exemplo n.º 1
0
        public async Task<ActionResult> Index(int? page)
        {
            MongoDBManager mm = new MongoDBManager();
            var movies = await mm.GetMovies();

            List<MovieListModel> listMovies = new List<MovieListModel>();

            foreach (var m in movies)
            {
                MovieListModel newMovie = new MovieListModel()
                {
                    AvgUserRating = m.AvgUserRating,
                    ID = m.ID,
                    Title = m.Title
                };
                var movie = await mm.GetMovie(m.ID);
                newMovie.Poster = movie.Poster;
                listMovies.Add(newMovie);
            }

            return View(listMovies.ToPagedList(page ?? 1, 12));
        }
Exemplo n.º 2
0
        public async Task<ActionResult> MovieRecommendations(int? page, string recommendationValue = "")
        {
            List<MovieListModel> moviesModel = new List<MovieListModel>();
            IMovieRecomendationProvider recomendation;
            ViewBag.recommendationValue = recommendationValue;
            switch (recommendationValue)
            {
                case "1":
                    recomendation = new GenreMovieRecomendations();
                    break;
                case "2":
                    recomendation = new ActorMovieRecomendations();
                    break;
                case "3":
                    recomendation = new MoviesBasedOnPeople();
                    break;
                default:
                    return View(moviesModel.ToPagedList(page ?? 1, 12));
            }

            List<Movie> movies = await recomendation.GetRecommendedMovies(User.Identity.GetUserId());

            foreach (var userMovie in movies)
            {
                MovieListModel newMovie = new MovieListModel()
                {
                    AvgUserRating = userMovie.AvgUserRating,
                    ID = userMovie.ID,
                    Title = userMovie.Title,
                    Poster = userMovie.Poster
                };

                moviesModel.Add(newMovie);
                
                
            }

            return View(moviesModel.ToPagedList(page ?? 1, 12));
        }        
Exemplo n.º 3
0
        public async Task<ActionResult> ShowUserMovies(int? page)
        {
            MongoDBManager mm = new MongoDBManager();
            UserInformation user = await mm.GetUserInformation(User.Identity.GetUserId());
            List<MovieListModel> movies = new List<MovieListModel>();

            if (user.MovieLikes != null)
            {
                foreach (var userMovie in user.MovieLikes)
                {
                    MovieListModel newMovie = new MovieListModel()
                    {
                        AvgUserRating = userMovie.UserRating,
                        ID = userMovie.Id,
                        Title = userMovie.Name
                    };
                    var movie = await mm.GetMovie(userMovie.Id);
                    newMovie.Poster = movie.Poster;
                    movies.Add(newMovie);
                }
            }

            return View(movies.ToPagedList(page ?? 1, 12));
        }