Exemplo n.º 1
0
        private static void Delete(this MusicDb musicDb, Track track, DeleteContext context)
        {
            long artistId = track.Work.ArtistId;

            foreach (var musicFile in track.MusicFiles.ToArray())
            {
                musicFile.Track = null;
                musicDb.Delete(musicFile, context);
            }
            var performance = track.Performance;

            performance?.Movements.Remove(track);
            if (performance?.Movements.Count() == 0)
            {
                musicDb.Delete(performance, context);
            }
            var work = track.Work;

            work?.Tracks.Remove(track);
            if (work?.Tracks.Count() == 0)
            {
                musicDb.Delete(work, context);
            }
            musicDb.Tracks.Remove(track);
            context.SetModifiedArtistId(artistId);
            log.Information($"{context}: Track [T-{track.Id}] deleted: {track.Title}");
        }
Exemplo n.º 2
0
        private static void Delete(this MusicDb musicDb, Performance performance, DeleteContext context)
        {
            long artistId = performance.Composition.ArtistId;

            foreach (var movement in performance.Movements)
            {
                movement.Performance = null;
                // we do not delete movements here because
                // a movement is a track and tracks are also in an album
            }
            performance.Movements.Clear();
            var composition = performance.Composition;

            composition?.Performances.Remove(performance);
            if (composition?.Performances.Count() == 0)
            {
                musicDb.Delete(composition, context);
            }
            musicDb.Performances.Remove(performance);
            context.SetModifiedArtistId(artistId);
            log.Information($"{context}: Performance [P-{performance.Id}] deleted: {performance.Performers}");
        }
Exemplo n.º 3
0
        private static void Delete(this MusicDb musicDb, Work work, DeleteContext context)
        {
            long artistId = work.ArtistId;

            foreach (var track in work.Tracks)
            {
                track.Work = null;
                musicDb.Delete(track, context);
            }
            var artist = work.Artist;

            artist?.Works.Remove(work);
            if (artist != null)
            {
                if (artist.Works.Count() == 0 && artist.Compositions.Count() == 0)
                {
                    musicDb.Delete(artist, context);
                }
            }
            musicDb.Works.Remove(work);
            context.SetModifiedArtistId(artistId);
            log.Information($"{context}: Work [W-{work.Id}] deleted: {work.Name}");
        }
Exemplo n.º 4
0
        private static void Delete(this MusicDb musicDb, Composition composition, DeleteContext context)
        {
            long artistId = composition.ArtistId;

            foreach (var performance in composition.Performances)
            {
                performance.Composition = null;
                musicDb.Delete(performance, context);
            }
            composition.Performances.Clear();
            musicDb.Compositions.Remove(composition);
            var artist = composition.Artist;

            artist?.Compositions.Remove(composition);
            if (artist != null)
            {
                if (artist.Works.Count() == 0 && artist.Compositions.Count() == 0)
                {
                    musicDb.Delete(artist, context);
                }
            }
            context.SetModifiedArtistId(artistId);
            log.Information($"{context}: Composition [C-{composition.Id}] deleted: {composition.Name}");
        }