public IActionResult Index() { IEnumerable <MoviePlaylist> playlistsFromDb = _playlistService.Get(); List <MoviePlaylistViewModel> vm = new List <MoviePlaylistViewModel>(); foreach (var pl in playlistsFromDb) { vm.Add(new MoviePlaylistViewModel { Naam = pl.Naam, Aantal = _playlistService.AantalMoviesInPlaylist(pl.Id), Id = pl.Id, Speelduur = _playlistService.TotaleSpeelduur(pl.Id) }); } return(View(vm)); }
public IActionResult AddToPlaylist(MovieDetailsViewModel model) { int playlistId = model.Playlist; var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (_playlistService.GetPlaylistsByUserId(userId).Contains(_playlistService.Get(playlistId))) { _playlistService.AssignMovieToPlaylist(model.Id, playlistId); } return(RedirectToAction("Details", new { movieId = model.Id })); }