public static void addToPlalist(int listID, int songID) { SQLManager.getInstance().Execute("INSERT INTO PlaylistSongs (playlistID, songID) VALUES (" + listID + ", " + songID + ");"); }
public static SQLManager getInstance() { if (Instance == null) Instance = new SQLManager(); return Instance; }
public static void deletePlaylist(int id) { try { SqlCommand delete = new SqlCommand("DELETE FROM PlaylistSongs WHERE playlistID = " + id.ToString() + ";", SQLManager.getInstance().connection); delete.ExecuteNonQuery(); delete = new SqlCommand("DELETE FROM Playlists WHERE Id = " + id.ToString() + ";", SQLManager.getInstance().connection); delete.ExecuteNonQuery(); } catch { } }
public static void createPlaylist(string name) { try { SqlCommand create = new SqlCommand("INSERT INTO Playlists (playlistName) VALUES ('" + HttpUtility.UrlEncode(name) + "');", SQLManager.getInstance().connection); create.ExecuteNonQuery(); } catch { } }
public static int getPlaylistID(string name) { int id = 0; try { SqlCommand select = new SqlCommand("SELECT * FROM Playlists WHERE playlistName = '" + HttpUtility.UrlEncode(name) + "';", SQLManager.getInstance().connection); SqlDataReader reader = select.ExecuteReader(); reader.Read(); id = Convert.ToInt32(reader["Id"].ToString()); reader.Close(); } catch { } return(id); }
public static void DeleteFromPlaylist(int playlist, int songID) { SQLManager.getInstance().Execute("DELETE FROM PlaylistSongs WHERE playlistID = " + playlist + " AND songID = " + songID + ";"); }
public static List <Song> getPlaylistContents(string name) { List <Song> SongList = new List <Song>(); int id = getPlaylistID(name); SqlCommand select = new SqlCommand("SELECT * FROM PlaylistSongs WHERE playlistID = " + id + ";", SQLManager.getInstance().connection); SqlDataReader reader = select.ExecuteReader(); List <int> SongIDSList = new List <int>(); while (reader.Read()) { SongIDSList.Add(Convert.ToInt32(reader["songID"])); } reader.Close(); for (int i = 0; i < SongIDSList.Count; i++) { SongList.Add(Library.getSongByID(SongIDSList[i])); } return(SongList); }