Exemplo n.º 1
0
 public void RaiseAlbumCreated(AlbumModel album)
 {
     if (AlbumCreated != null)
     {
         AlbumCreated(this, new AlbumCreatedEventArgs(album));
     }
 }
Exemplo n.º 2
0
        public async void DeleteAlbum(int albumId)
        {
            if (albumLookupDictionary.ContainsKey(albumId))
            {
                AlbumModel albumToRemove = albumLookupDictionary[albumId];

                albumToRemove.DeleteArt();

                AllAlbums.Remove(albumToRemove);
                albumLookupDictionary.Remove(albumId);
            }

            DatabaseManager.Current.DeleteAlbum(albumId);
        }
Exemplo n.º 3
0
        public AlbumModel LookupAlbumByName(string albumName, int albumArtistId)
        {
            AlbumTable albumTable = DatabaseManager.Current.LookupAlbum(albumName, albumArtistId);

            if (albumTable == null)
            {
                AlbumTable newAlbum = new AlbumTable(string.Empty, albumArtistId, albumName, 0);
                DatabaseManager.Current.AddAlbum(newAlbum);

                AlbumModel albumModel = new AlbumModel(newAlbum);
                albumLookupDictionary.Add(albumModel.AlbumId, albumModel);

                RaiseAlbumCreated(albumModel);

                return(albumModel);
            }
            else
            {
                return(LookupAlbumById(albumTable.AlbumId));
            }
        }
Exemplo n.º 4
0
        public AlbumModel LookupAlbumById(int albumId)
        {
            if (albumLookupDictionary.ContainsKey(albumId))
            {
                return(albumLookupDictionary[albumId]);
            }
            else
            {
                AlbumTable albumTable = DatabaseManager.Current.LookupAlbumById(albumId);

                if (albumTable == null)
                {
                    return(null);
                }
                else
                {
                    AlbumModel albumModel = new AlbumModel(albumTable);
                    albumLookupDictionary.Add(albumModel.AlbumId, albumModel);

                    return(albumModel);
                }
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public AlbumCreatedEventArgs(AlbumModel album)
     : base()
 {
     this.NewAlbum = album;
 }
Exemplo n.º 7
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");
        }