public static List <SpotifyPlaylist> GetUserPlaylists(AppDbContext context)
        {
            var authObj = context.AuthenticationObjects.FirstOrDefault();
            var result  = new List <SpotifyPlaylist>();

            if (authObj == null)
            {
                return(result);
            }

            var user = ClientApi.QueryServiceForCurrentUser(authObj);

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", authObj.access_token);

                var response = client.GetAsync($"https://api.spotify.com/v1/users/{user.id}/playlists").Result;

                var responseContent = response.Content.ReadAsStringAsync().Result;

                var jobj      = JObject.Parse(responseContent);
                var playlists = JsonConvert.DeserializeObject <List <SpotifyPlaylist> >(jobj["items"].ToString());

                result = playlists.ToList();
            }

            return(result);
        }
        public static void ProcessPlaylistRequest(PlaylistRequest request, AppDbContext context)
        {
            var authObj = context.AuthenticationObjects.FirstOrDefault();

            if (authObj == null)
            {
                return;
            }

            var user = ClientApi.QueryServiceForCurrentUser(authObj);

            var playlist = CreatePlaylist(request, authObj, user);
            var tracks   = GenerateTracksForPlaylist(authObj, request).ToList();

            AddTracksToPlaylist(authObj, playlist, tracks);
        }