Esempio n. 1
0
        public void DeleteArtist(int artistId)
        {
            if (artistLookupDictionary.ContainsKey(artistId))
            {
                ArtistModel modelToRemove = artistLookupDictionary[artistId];

                AllArtists.Remove(modelToRemove);

                artistLookupDictionary.Remove(artistId);
            }

            DatabaseManager.Current.DeleteArtist(artistId);
        }
Esempio n. 2
0
        public ArtistModel LookupArtistByName(string artistName)
        {
            ArtistTable artistTable = DatabaseManager.Current.LookupArtist(artistName);

            if (artistTable == null)
            {
                ArtistTable newArtist = new ArtistTable(artistName);
                DatabaseManager.Current.AddArtist(newArtist);

                ArtistModel artistModel = new ArtistModel(newArtist);
                artistLookupDictionary.Add(artistModel.ArtistId, artistModel);

                return(artistModel);
            }
            else
            {
                return(LookupArtistById(artistTable.ArtistId));
            }
        }
Esempio n. 3
0
        public ArtistModel LookupArtistById(int artistId)
        {
            if (artistLookupDictionary.ContainsKey(artistId))
            {
                return(artistLookupDictionary[artistId]);
            }
            else
            {
                ArtistTable artistTable = DatabaseManager.Current.LookupArtistById(artistId);

                if (artistTable == null)
                {
                    return(null);
                }
                else
                {
                    ArtistModel artistModel = new ArtistModel(artistTable);
                    artistLookupDictionary.Add(artistModel.ArtistId, artistModel);

                    return(artistModel);
                }
            }
        }
Esempio n. 4
0
        public SongModel AddNewSong(string artist, string album, string albumArtist, string title, string path, SongOriginSource origin, long duration, uint rating, uint trackNumber)
        {
            ArtistModel artistModel = LookupArtistByName(artist);

            ArtistModel albumArtistModel = LookupArtistByName(albumArtist);

            AlbumModel albumModel = LookupAlbumByName(album, albumArtistModel.ArtistId);

            SongModel currentTableEntry = LookupSongByPath(path);

            if (currentTableEntry == null)
            {
                SongTable newSong = new SongTable(albumModel.AlbumId, artistModel.ArtistId, duration, 0, title, origin, 0, rating, path, trackNumber);
                DatabaseManager.Current.AddSong(newSong);

                SongModel songModel = new SongModel(newSong);
                _allSongs.Add(songModel);
                songLookupDictionary.Add(songModel.SongId, songModel);

                return(songModel);
            }

            return(null);
        }
Esempio n. 5
0
        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");
        }