public IActionResult RateMovie(MovieRateViewModel model)
        {
            var movie         = _mediaService.GetAllMedia().OfType <Movie>().First(mov => mov.Id == model.MediaId);
            var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);
            var user          = _mediaService.GetAllMediaUsers().Where(prof => prof.Id == currentUserId).FirstOrDefault();

            var newRating = new Rating()
            {
                Media        = movie,
                CreationDate = DateTime.Now,
                Points       = model.Points,
                Review       = model.Review,
                MediaUser    = user
            };

            _mediaService.InsertRating(newRating);
            _mediaService.SaveChanges();
            return(RedirectToAction("Details", new { movie.Id }));
        }
        public IActionResult RatePodcast(PodcastRateViewModel model)
        {
            var podcast       = _mediaService.GetAllPodcasts().First(pod => pod.Id == model.MediaId);
            var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);


            _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId);

            var newRating = new Rating()
            {
                Media        = podcast,
                CreationDate = DateTime.Now,
                Points       = model.Points,
                MediaUser    = _currentMediaUser
            };

            _mediaService.InsertRating(newRating);
            _mediaService.SaveChanges();

            return(RedirectToAction("Details", new { podcast.Id }));
        }
        public IActionResult RateMusic(MusicRateViewModel model)
        {
            var music         = _mediaService.GetAllMedia().OfType <Music>().First(muz => muz.Id == model.MediaId);
            var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);


            _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId);


            var newRating = new Rating()
            {
                Media        = music,
                CreationDate = DateTime.Now,
                Points       = model.Points,
                MediaUser    = _currentMediaUser
            };

            _mediaService.InsertRating(newRating);
            _mediaService.SaveChanges();

            return(RedirectToAction("Details", new { music.Id }));
        }
        public IActionResult RateEpisode(EpisodeRateViewModel model)
        {
            var episode       = _mediaService.GetAllEpisodes().First(epi => epi.Id == model.MediaId);
            var isSignedIn    = this._signInManager.IsSignedIn(HttpContext.User);
            var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User);

            if (isSignedIn)
            {
                _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId);
            }

            var newRating = new Rating()
            {
                Media        = episode,
                CreationDate = DateTime.Now,
                Points       = model.Points,
                MediaUser    = _currentMediaUser
            };

            _mediaService.InsertRating(newRating);
            _mediaService.SaveChanges();
            return(RedirectToAction("Details", new { episode.Id }));
        }