Beispiel #1
0
        public async Task <string> SaveAsync(SavePlaylistFormViewModel form)
        {
            var userId = _httpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value;


            JObject playlistCreateResult = await PostRequest(
                JObject.FromObject(new { name = form.Name }),
                $"https://api.spotify.com/v1/users/{userId}/playlists");

            var playlistId  = playlistCreateResult["id"].ToString();
            var playlistUrl = playlistCreateResult["external_urls"]["spotify"].ToString();

            JObject playlistAddTracksResult = await PostRequest(
                JObject.FromObject(new { uris = form.GenerateSpotifyUris() }),
                $"https://api.spotify.com/v1/users/{userId}/playlists/{playlistId}/tracks");

            return(playlistUrl);
        }
Beispiel #2
0
        public async Task <IActionResult> SavePlaylist(SavePlaylistFormViewModel form)
        {
            ViewData["url"] = await _playlistSaver.SaveAsync(form);

            return(View());
        }