示例#1
0
 /// <summary>
 /// Delete the specified Artist from the storage and the collections
 /// </summary>
 /// <param name="artistAlbumToDelete"></param>
 /// <returns></returns>
 public static void DeleteArtist(Artist artistToDelete)
 {
     // No need to wait for the Artist to be removed from storage
     DbAccess.DeleteAsync(artistToDelete);
     ArtistCollection.Remove(artistToDelete);
     IdLookup.Remove(artistToDelete.Id);
 }
示例#2
0
        public Track UpdateTrack(RawTrack track)
        {
            Track old;

            if (!_trackDict.TryGetValue(track.FullFilename, out old))
            {
                throw new ArgumentException(track.FullFilename + " was not found in library - use Add instead.", "track");
            }

            old.Title       = track.TrackTitle;
            old.Tracknumber = track.TrackNumberUnknown ? (int?)null : track.TrackNumber;

            Album album = _albums[track.AlbumTitle] ?? CreateAlbum(track.AlbumTitle, track.Year);

            if (album != old.Album)
            {
                old.Album.Tracks.Remove(old);
                if (old.Album.Tracks.Count == 0)
                {
                    _albums.Remove(old.Album);
                }

                old.Album = album;
                album.Tracks.Add(old);
            }
            else
            {
                album.Tracks.Reposition(old);
            }

            Artist artist = _artists[track.ArtistName] ?? CreateArtist(track.ArtistName);

            if (artist != old.Artist)
            {
                Artist oldArtist = old.Artist;
                old.Artist = artist;

                old.Album.Tracks.Remove(old);
                old.Album.Tracks.Add(old);
                if (oldArtist.Albums.Count == 0)
                {
                    _artists.Remove(oldArtist);
                }
            }

            return(old);
        }
示例#3
0
        /// <summary>
        /// Delete the specified Artists from the storage and the collections
        /// </summary>
        /// <param name="artistsToDelete"></param>
        public static void DeleteArtists(IEnumerable <Artist> artistsToDelete)
        {
            DbAccess.DeleteItemsAsync(artistsToDelete);

            foreach (Artist artistToDelete in artistsToDelete)
            {
                ArtistCollection.Remove(artistToDelete);
                IdLookup.Remove(artistToDelete.Id);
            }
        }
示例#4
0
        internal void RemoveArtistIfNeeded(ArtistViewModel artistViewModel)
        {
            if (artistViewModel.Songs.Count == 0 && artistViewModel.Albums.Count == 0)
            {
                ArtistCollection.Remove(artistViewModel, artistViewModel.SortName);
                ArtistLookupMap.Remove(artistViewModel.ArtistId);

                artistViewModel.IsBeingDeleted = true;

                LibraryModel.Current.DeleteArtist(artistViewModel.ArtistId);
            }
        }