Ejemplo n.º 1
0
        public static CosmosPlaylist formatToCosmosDBDocument(Playlist playlist)
        {
            var tracks = new List <CosmosTrack>();

            foreach (var item in playlist.tracks.items)
            {
                var track = new CosmosTrack(
                    item.track.id,
                    item.track.name,
                    item.track.popularity,
                    item.track.preview_url,
                    item.track.uri
                    );
                var artists = new List <string>();
                foreach (var artist in item.track.artists)
                {
                    artists.Add(artist.name);
                }
                track.artists = artists;
                tracks.Add(track);
            }

            var cosmos_playlist = new CosmosPlaylist(
                playlist.id,
                playlist.name,
                playlist.description,
                playlist.followers.total,
                tracks,
                playlist.uri
                );

            return(cosmos_playlist);
        }
Ejemplo n.º 2
0
 public void AppendTracks(Tracks tracks)
 {
     foreach (var item in tracks.items)
     {
         var track = new CosmosTrack(
             item.track.id,
             item.track.name,
             item.track.popularity,
             item.track.preview_url,
             item.track.uri
             );
         var artists = new List <string>();
         foreach (var artist in item.track.artists)
         {
             artists.Add(artist.name);
         }
         track.artists = artists;
         this.tracks.Add(track); // Append new tracks to existing object
     }
 }