public void AddPlaylist(string name) { PlaylistTable table = new PlaylistTable(name); DatabaseManager.Current.AddPlaylist(table); PlaylistModel playlistModel = new PlaylistModel(table); Playlists.Add(playlistModel); playlistLookupDictionary.Add(playlistModel.PlaylistId, playlistModel); }
public void DeletePlaylist(int playlistId) { if (playlistLookupDictionary.ContainsKey(playlistId)) { PlaylistModel playlistModel = playlistLookupDictionary[playlistId]; Playlists.Remove(playlistModel); playlistLookupDictionary.Remove(playlistId); } DatabaseManager.Current.DeletePlaylist(playlistId); }
private void LoadCollection() { PerfTracer perfTracer = new PerfTracer("LibraryModel Loading"); IEnumerable <SongTable> allSongs = DatabaseManager.Current.FetchSongs(); foreach (SongTable songEntry in allSongs) { SongModel songModel = new SongModel(songEntry); _allSongs.Add(songModel); songLookupDictionary.Add(songModel.SongId, songModel); } perfTracer.Trace("Songs Added"); IEnumerable <AlbumTable> allAlbums = DatabaseManager.Current.FetchAlbums(); foreach (AlbumTable albumEntry in allAlbums) { AlbumModel albumModel = new AlbumModel(albumEntry); _allAlbums.Add(albumModel); albumLookupDictionary.Add(albumModel.AlbumId, albumModel); } perfTracer.Trace("Albums Added"); IEnumerable <ArtistTable> allArtists = DatabaseManager.Current.FetchArtists(); foreach (ArtistTable artistEntry in allArtists) { ArtistModel artistModel = new ArtistModel(artistEntry); _allArtists.Add(artistModel); artistLookupDictionary.Add(artistModel.ArtistId, artistModel); } perfTracer.Trace("Artists Added"); IEnumerable <PlaylistTable> allPlaylists = DatabaseManager.Current.FetchPlaylists(); foreach (PlaylistTable playlistEntry in allPlaylists) { PlaylistModel playlistModel = new PlaylistModel(playlistEntry); Playlists.Add(playlistModel); playlistLookupDictionary.Add(playlistModel.PlaylistId, playlistModel); playlistModel.Populate(); } perfTracer.Trace("Playlists Added"); IEnumerable <MixTable> allMixes = DatabaseManager.Current.FetchMixes(); foreach (MixTable mixEntry in allMixes) { MixModel mixModel = new MixModel(mixEntry); Mixes.Add(mixModel); mixLookupDictionary.Add(mixModel.MixId, mixModel); mixModel.Populate(); } perfTracer.Trace("Mixes Added"); }