Пример #1
0
        public MovieComplete GetMovieDetail(int id)
        {
            var movie         = _db.Movies.First(r => r.MovieID == id);
            var movieDetail   = _db.MovieDetails.First(r => r.MovieID == id).MovieDetailDto();
            var criticRatings = _db.CriticRatings.Where(r => r.MovieDetailID == movieDetail.MovieDetailID);
            var userRating    = _db.UserRatings.FirstOrDefault(r => r.MovieDetailID == movieDetail.MovieDetailID)?.UserRatingDto();
            var criticsites   = criticRatings.Select(criticRating => criticRating.CriticSite);

            return(new MovieComplete
            {
                Movie = movie.MovieDto(),
                MovieDetail = movieDetail,
                UserRatings = userRating,
                CriticRatings = CriticRating.CriticRatingLsitDto(criticRatings).ToList(),
                CriticSites = CriticSite.CriticSiteLsitDto(criticsites).ToList()
            });
        }
Пример #2
0
        // GET: Movie/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var movie         = _db.Movies.First(r => r.MovieID == id);
            var movieDetail   = _db.MovieDetails.First(r => r.MovieID == id).MovieDetailDto();
            var criticRatings = _db.CriticRatings.Where(r => r.MovieDetailID == movieDetail.MovieDetailID);
            var userRating    = _db.UserRatings.FirstOrDefault(r => r.MovieDetailID == movieDetail.MovieDetailID)?.UserRatingDto();
            var criticsites   = criticRatings.Select(criticRating => criticRating.CriticSite);
            var ViewModel     = new MovieDetailViewModel(new MovieComplete
            {
                Movie         = movie.MovieDto(),
                MovieDetail   = movieDetail,
                UserRatings   = userRating,
                CriticRatings = CriticRating.CriticRatingLsitDto(criticRatings).ToList(),
                CriticSites   = CriticSite.CriticSiteLsitDto(criticsites).ToList()
            });

            return(View(ViewModel));
        }