/// <summary> /// Get an existing Artist or create a new one. /// </summary> /// <param name="artistName"></param> /// <returns></returns> private async Task <Artist> GetArtistToHoldSongsAsync(string artistName) { // Find the Artist for this song. The 'scanLibrary' can be used for this search as it is already fully populated with the // artists Artist songArtist = artistsInLibrary.GetValueOrDefault(artistName.ToUpper()); Logger.Log(string.Format("Artist: {0} {1}", artistName, (songArtist != null) ? "found" : "not found creating in db")); if (songArtist == null) { // Create a new Artist and add it to the database songArtist = new Artist() { Name = artistName, ArtistAlbums = new List <ArtistAlbum>(), LibraryId = scanLibrary }; await Artists.AddArtistAsync(songArtist); // Add it to the collection for this library only artistsInLibrary[songArtist.Name.ToUpper()] = songArtist; } return(songArtist); }