public ActionResult View(string key) { if (User != null) { user = userManager.ReadUser(User.Identity.Name); } var playlist = playlistManager.ReadPlaylistByKey(key); var votesUser = playlistManager.ReadVotesForUser(user); var organisation = organisationManager.ReadOrganisationForPlaylist(playlist.Id); var playlistOwners = new List <User>(); if (organisation != null) { playlistOwners = userManager.ReadCoOrganiserFromOrganisation(organisation).ToList(); playlistOwners.Add(userManager.ReadOrganiserFromOrganisation(organisation)); } else { if (playlist.CreatedById != null) { playlistOwners.Add(userManager.ReadUser((long)playlist.CreatedById)); } } ViewBag.Organisation = organisationManager.ReadOrganisationForPlaylist(playlist.Id); ViewBag.CurrentUser = user; ViewBag.Organisers = playlistOwners; ViewBag.VotesUser = votesUser; ViewBag.PlaylistId = playlist.Id; ViewBag.PlaylistKey = playlist.Key; ViewBag.HistoryCount = playlist.PlaylistTracks.Count(t => t.PlayedAt != null); playlist.PlaylistTracks = playlist.PlaylistTracks.Where(t => t.PlayedAt == null).ToList(); return(View(playlist)); }