示例#1
0
        public IActionResult SpotifySignin(string code, string state, string error)
        {
            if (error != string.Empty)
            {
            }
            var spotify = new Spotify();
            var tokens  = spotify.GenerateAccessRefreshTokens(code, GenerateRedirectUri());
            var data    = new UserData()
            {
                AccessToken  = tokens.access_token,
                RefreshToken = tokens.refresh_token,
                JukeBoxId    = state,
            };
            var db = new Db();

            db.InsertData(data);

            data.PlaylistId = spotify.CreateNewPlaylist(data); // sets the playlist id in userdata

            db.UpdatePlaylistId(data);
            ViewBag.Message = $"Success, playlist created";
            return(View("Search", new SearchModel()
            {
                PlaylistId = data.JukeBoxId, Songs = new List <Song>()
            }));
        }