public ActionResult MoviesSeriesDetails(int id)
        {
            User user = _userService.GetUsersByUserName(User.Identity.GetUserName());
            List <MoviesSeriesEmployee> employeesOfMoviesSeries = _moviesSeriesEmployeeService.GetEmployeeByMoviesSeriesId(id);

            MoviesSeries moviesSeries = _moviesSeriesService.GetMoviesSeriesById(id);

            if (user != null)
            {
                List <MoviesSeriesWatchList> moviesSeriesWatchList = _moviesSeriesWatchListService.GetMoviesSeriesWatchListByWatchList(user.UserID);
                Rating rating = _ratingService.GetScoreByUserAndMovie(user.UserID, id);
                ViewBag.rating  = rating;
                ViewBag.comment = _ratingService.GetCommentByUserAndMovie(user.UserID, id);
                count           = moviesSeriesWatchList.Where(x => x.MoviesSeriesID == id).ToList().Count();
            }

            ViewBag.AllComment = _ratingService.GetCommentByUserAndMovieWithInclude(id, "User", "RatingOfMovieSeries");

            int     score = 0;
            decimal averageImdb;
            int     ratingCount = _ratingService.GetRatingByMoviesID(id).Count();

            foreach (var item in _ratingService.GetRatingByMoviesID(id))
            {
                score += item.Score;
            }
            if (ratingCount > 0 && score > 0)
            {
                averageImdb = (decimal)score / ratingCount;
            }
            else
            {
                averageImdb = 0;
            }

            moviesSeries.AverageRating = Decimal.Round(averageImdb, 1);


            if (count != 0)
            {
                ViewBag.DoesExistMovieInWatchList = true;
            }
            else
            {
                ViewBag.DoesExistMovieInWatchList = false;
            }

            employees = new List <Employee>();
            foreach (var item in employeesOfMoviesSeries)
            {
                employees.Add(_employeeService.GetEmployeeById(item.EmployeeID));
            }
            ViewBag.EmployeeOfMoviesSeries = employees;

            _moviesSeriesService.Update(moviesSeries);

            return(View(_moviesSeriesService.GetMoviesSeriesById(id)));
        }
예제 #2
0
        public ActionResult WatchList()
        {
            User user = _userService.GetUsersByUserName(User.Identity.GetUserName());

            moviesSeriesList = new List <MoviesSeries>();
            List <MoviesSeriesWatchList> moviesSeriesWatchList = _moviesSeriesWatchListService.GetMoviesSeriesWatchListByWatchList(user.UserID);

            foreach (var item in moviesSeriesWatchList)
            {
                moviesSeriesList.Add(_moviesSeriesService.GetMoviesSeriesById(item.MoviesSeriesID));
            }
            ViewBag.WatchList = moviesSeriesList;
            return(View(user));
        }