public IEnumerable <Playlist> GetCurrentUserPlaylists() { using (var user = StateManager.CurrentUser) { if (user.SpotifyAuthTokens != null) { var playlistsResponse = SpotifyServices.GetPlaylists(user.SpotifyAuthTokens); if (playlistsResponse != null && playlistsResponse.PlayLists != null) { return(playlistsResponse.PlayLists); } } } return(Enumerable.Empty <PlaylistWithLoadedTracks>()); }
public GetTracksFromCurrentUserPlaylistResponse GetTracksFromCurrentUserPlaylist(string listId) { GetTracksFromCurrentUserPlaylistResponse response = new GetTracksFromCurrentUserPlaylistResponse { PlaylistId = listId }; using (var user = StateManager.CurrentUser) { var playlistsResponse = SpotifyServices.GetPlaylists(user.SpotifyAuthTokens); var playlist = playlistsResponse.PlayLists.FirstOrDefault(list => list.Id == listId); if (playlist != null) { response.Tracks = SpotifyServices.GetTracksFromPlaylist(playlist, user.SpotifyAuthTokens).ToArray(); } } return(response); }