Exemple #1
0
 public static void addToPlalist(int listID, int songID)
 {
     SQLManager.getInstance().Execute("INSERT INTO PlaylistSongs (playlistID, songID) VALUES (" + listID + ", " + songID + ");");
 }
Exemple #2
0
 public static SQLManager getInstance()
 {
     if (Instance == null)
         Instance = new SQLManager();
     return Instance;
 }
Exemple #3
0
        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 { }
        }
Exemple #4
0
 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 { }
 }
Exemple #5
0
        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);
        }
Exemple #6
0
 public static void DeleteFromPlaylist(int playlist, int songID)
 {
     SQLManager.getInstance().Execute("DELETE FROM PlaylistSongs WHERE playlistID = " + playlist + " AND songID = " + songID + ";");
 }
Exemple #7
0
        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);
        }