public void AddPlaylistToTable(string playlist_name, string playlistId) { SpotifyAPIGetData p = new SpotifyAPIGetData(); spotifyPlaylist playlist = p.GetPlaylist(playlistId); string d = "DELETE FROM dbo.Playlists WHERE Playlist = '" + playlist_name + "'"; SqlCommand del = new SqlCommand(d, connection); try { del.ExecuteNonQuery(); } catch (Exception e) { MessageBox.Show("Something Went Wrong, Please Try Again Later ://"); } foreach (songInfo song in playlist.items) { spotifyTrack t = song.track; string title = t.name.Replace("'", "''"); List <string> artists = new List <string>(); foreach (artistInfo a in t.artists) { artists.Add(a.name); } string artistString = String.Join(", ", artists).Replace("'", "''"); string album = t.album.name.Replace("'", "''"); int @explicit = (t.@explicit) ? 1 : 0; TimeSpan duration = TimeSpan.FromMilliseconds(t.duration_ms); int popularity = t.popularity; string trackId = t.id.Replace("'", "''"); string release_date = t.album.release_date; string c = String.Format("EXEC dbo.insertPlaylistData @Playlist = '{0}', @Title = '{1}', @Artist = '{2}', @Album = '{3}', @Explicit = {4}, @Duration = '{5}', @Popularity = {6}, @Release_Date = '{7}', @ID = '{8}'", playlist_name, title, artistString, album, @explicit, duration, popularity, release_date, trackId); SqlCommand command = new SqlCommand(c, connection); try { command.ExecuteNonQuery(); } catch (Exception e) { MessageBox.Show("Something Went Wrong, Please Try Again Later ://"); } } }
private void start() { server = new SQLServer(); server.openConnection(); spotify = new SpotifyAPIGetData(); artistTracks = server.GetAllArtistSongs(); AddPlaylistGrid.Visibility = Visibility.Collapsed; Add_PlaylistID_TextBox.Text = ""; Add_PlaylistName_Label.Content = ""; UpdatePlaylistGrid.Visibility = Visibility.Collapsed; PlaylistNameID = server.GetPlaylistNameID(); GetPlaylistGrid.Visibility = Visibility.Collapsed; }
public TrackInfo() { InitializeComponent(); spotify = new SpotifyAPIGetData(); }