public static PlaylistMusique Create(PlaylistMusique playlistMusique) { using (SqlConnection connection = DataBase.GetConnection()) { connection.Open(); SqlCommand command = new SqlCommand(CREATE, connection); command.Parameters.AddWithValue("@id_musique", playlistMusique.Id_musique); command.Parameters.AddWithValue("@id_playlist", playlistMusique.Id_Playlist); command.ExecuteScalar(); } return(playlistMusique); }
public static PlaylistMusique Get(int id_musique, int id_playlist) { PlaylistMusique playlistMusique = null; using (SqlConnection connection = DataBase.GetConnection()) { connection.Open(); SqlCommand command = new SqlCommand(GET, connection); command.Parameters.AddWithValue("@id_musique", id_musique); command.Parameters.AddWithValue("@id_playlist", id_playlist); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { playlistMusique = new PlaylistMusique(reader.GetInt32(0), reader.GetInt32(1)); } } return(playlistMusique); }