/// <summary> /// Add a list of songs to the playlist /// </summary> /// <param name="playlist"></param> /// <param name="songs"></param> public void AddSongs(IEnumerable <Song> songs) { List <SongPlaylistItem> songPlaylistItems = new(); // For each song create a PlayListItem and add to the PlayList foreach (Song song in songs) { song.Artist = Artists.GetArtistById(ArtistAlbums.GetArtistAlbumById(song.ArtistAlbumId).ArtistId); SongPlaylistItem itemToAdd = new() { Artist = song.Artist, PlaylistId = Id, Song = song, SongId = song.Id, Index = PlaylistItems.Count }; songPlaylistItems.Add(itemToAdd); PlaylistItems.Add(itemToAdd); } // No need to wait for this DbAccess.InsertAllAsync(songPlaylistItems); }
/// <summary> /// Add a list of albums to the playlist /// </summary> /// <param name="albums"></param> public void AddAlbums(IEnumerable <Album> albums) { // For each song create an AlbumPlayListItem and add to the PlayList List <AlbumPlaylistItem> albumPlaylistItems = new(); foreach (Album album in albums) { AlbumPlaylistItem itemToAdd = new() { Album = album, PlaylistId = Id, AlbumId = album.Id, Index = PlaylistItems.Count }; PlaylistItems.Add(itemToAdd); albumPlaylistItems.Add(itemToAdd); } // No need to wait for this to complete DbAccess.InsertAllAsync(albumPlaylistItems); }