public async Task <IActionResult> Playlist(List <long> artistIds, int numberOfTracks) { var user = await _userManager.GetUserAsync(User); var artists = await _artistService.GetArtistsById(artistIds); var topTracks = await _spotifyService.GetMostPopularTracks(artists, user.SpotifyUserId, numberOfTracks); var model = new PlaylistViewModel { Playlist = await _spotifyService.CreatePlaylist(topTracks, user.SpotifyUserId) }; return(View(model)); }
public async Task <ActionResult <Playlist> > CreatePlaylist(string userId, [FromBody] CreatePlaylistCommand command) { var user = await _userService.GetUserById(userId); var artists = await _artistService.GetArtistsById(command.ArtistIds); var topTracks = await _spotifyService.GetMostPopularTracks(artists, user.SpotifyUserId, command.NumberOfTracks); var playlist = await _spotifyService.CreatePlaylist(topTracks, user.SpotifyUserId); playlist.OwnedBy = null; return(Created(playlist.SpotifyId, playlist)); }