Exemplo n.º 1
0
        private void buildLocalPlaylistModels()
        {
            foreach (var list in Service.Library.Playlists)
            {
                var playlist = new LocalPlaylistModel
                {
                    Playlist = Service.Library.Playlists.Where(p => p.Id == list.Id).FirstOrDefault(),
                };
                Playlists.Add(playlist);
            }

            foreach (var pair in Service.Library.MInP)
            {
                var playlist = Playlists.Where(p => p.Playlist.Id == pair.PlaylistId).FirstOrDefault();
                var music    = Musics.Where(m => m.Music.Id == pair.MusicId).FirstOrDefault();
                playlist.Musics.Add(music);
            }
        }
Exemplo n.º 2
0
        private void UpdatePlaylists()
        {
            try
            {
                List <LocalPlaylistModel> list = new List <LocalPlaylistModel>();

                foreach (var playlist in Service.Library.Playlists)
                {
                    if (!Playlists.Select(p => p.Playlist.Id).ToList().Contains(playlist.Id))
                    {
                        var playlistModel = new LocalPlaylistModel
                        {
                            Playlist = playlist
                        };
                        Playlists.Add(playlistModel);
                        list.Add(playlistModel);
                    }
                }

                foreach (var pair in Service.Library.MInP)
                {
                    var playlist = Playlists.Where(p => p.Playlist.Id == pair.PlaylistId).FirstOrDefault();
                    var music    = Musics.Where(m => m.Music.Id == pair.MusicId).FirstOrDefault();
                    if (!playlist.Musics.Contains(music))
                    {
                        playlist.Musics.Add(music);
                    }
                }

                Playlists = new ObservableCollection <LocalPlaylistModel>(Playlists.OrderBy(p => p.Playlist.Name).ToList());

                foreach (var playlist in Playlists)
                {
                    playlist.LibraryViewModel = this;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }