Example #1
0
        /// <summary>
        /// Get an existing or new ArtistAlbum entry to hold the songs associated with a particular Artist
        /// </summary>
        /// <param name="songArtist"></param>
        /// <param name="songAlbum"></param>
        /// <returns></returns>
        private async Task <ArtistAlbum> GetArtistAlbumToHoldSongsAsync(Artist songArtist, Album songAlbum)
        {
            ArtistAlbum songArtistAlbum = null;

            // Find an existing or create a new ArtistAlbum entry
            songArtistAlbum = songArtist.ArtistAlbums.SingleOrDefault(p => (p.Name.ToUpper() == songAlbum.Name.ToUpper()));

            Logger.Log(string.Format("ArtistAlbum: {0} {1}", songAlbum.Name, (songArtistAlbum != null) ? "found" : "not found creating in db"));

            if (songArtistAlbum == null)
            {
                // Create a new ArtistAlbum and add it to the database and the Artist
                songArtistAlbum = new ArtistAlbum()
                {
                    Name   = songAlbum.Name, Album = songAlbum, Songs = new List <Song>(), ArtistId = songArtist.Id,
                    Artist = songArtist, AlbumId = songAlbum.Id
                };
                await ArtistAlbums.AddArtistAlbumAsync(songArtistAlbum);

                songArtist.ArtistAlbums.Add(songArtistAlbum);
            }
            else
            {
                // Get the children of the existing ArtistAlbum
                if (songArtistAlbum.Songs == null)
                {
                    songArtistAlbum.Songs = Songs.GetArtistAlbumSongs(songArtistAlbum.Id);
                }
            }

            return(songArtistAlbum);
        }
Example #2
0
 public void GetArtistAlbumSongs(ArtistAlbum artistAlbum)
 {
     if (artistAlbum.Songs == null)
     {
         artistAlbum.Songs = Songs.GetArtistAlbumSongs(artistAlbum.Id);
         artistAlbum.Songs.Sort((a, b) => a.Track.CompareTo(b.Track));
     }
 }
Example #3
0
        /// <summary>
        /// Get the contents for the Artist
        /// The ArtistAlbum entries have already been obtained so just get the Songs for them
        /// </summary>
        /// <param name="theArtist"></param>
        public void GetSongs()
        {
            if (songsRead == false)
            {
                foreach (ArtistAlbum artistAlbum in ArtistAlbums)
                {
                    artistAlbum.Songs = Songs.GetArtistAlbumSongs(artistAlbum.Id);
                    artistAlbum.Songs.Sort((a, b) => a.Track.CompareTo(b.Track));
                }
            }

            songsRead = true;
        }