public IActionResult Details(int id) { 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 episode = _mediaService.GetAllEpisodes().FirstOrDefault(epi => epi.Id == id); var isRated = false; var playLists = new List <PlayList>(); var AveragePoints = 0.0; if (_currentMediaUser != null) { isRated = _mediaService.GetAllRatings().Where(epi => epi.Media.Id == epi.Id && epi.MediaUser.Id == _currentMediaUser.Id).Any(); playLists = _currentMediaUser.Playlists.ToList(); } var points = _mediaService.GetAllRatings().Where(epi => epi.Media.Id == epi.Id).Average(epi => epi.Points); AveragePoints = _mediaService.GetAllRatings().Where(epi => epi.Media.Id == epi.Id).Average(epi => epi.Points); EpisodeDetailViewModel model = new EpisodeDetailViewModel() { MediaId = episode.Id, SeasonNr = episode.Season.SeasonNr, Description = episode.Description, Duration = episode.Duration, Photo = episode.Photo, ReleaseDate = episode.ReleaseDate, IMDBLink = episode.IMDBLink, Titel = episode.Titel, IsRated = isRated, IsSignedIn = isSignedIn, PlayLists = playLists, AveragePoints = AveragePoints }; return(View(model)); }