/// <summary>
        /// Adds a given playlist to the db
        /// </summary>
        /// <param name="playlistToAddToDataBase">The playlist to add to the database</param>
        public void InsertPlaylistToDb(Playlist playlistToAddToDataBase)
        {
            PlaylistModel playlistModel = playlistOperationsHelper.CreatePlaylistModelWithMetaData(playlistToAddToDataBase);

            playlistModel = playlistOperationsHelper.AddRelatingItemsToPlaylistModel(playlistToAddToDataBase, playlistModel);

            dbContext.Playlists.Add(playlistModel);
            dbContext.SaveChanges();
        }
示例#2
0
        /// <summary>
        /// Delete all PlaylistData in the database
        /// </summary>
        internal void DeleteAllPlaylistDataFromDatabase()
        {
            List <PlaylistModel> playlists = GetPlaylists();

            foreach (PlaylistModel playlist in playlists)
            {
                RemoveRelationsToPlaylist(playlist);
                dbContext.Playlists.Remove(playlist);

                RemoveParentTreeViewNode(playlist);
            }
            dbContext.SaveChanges();
        }