示例#1
0
        internal bool AddSong(StorageProviderSong song, bool resetSongData)
        {
            SongModel songFromSource = LibraryModel.Current.GetSongFromSource(StorageProviderSourceToSongOriginSource(song.Origin), song.Source);

            if (songFromSource != null)
            {
                if (resetSongData)
                {
                    SongViewModel songViewModel = LookupSong(songFromSource);

                    songViewModel.Name = song.Name;

                    songViewModel.ArtistName = song.Artist;

                    string newAlbumName      = song.Album;
                    string newAlbumAristName = song.AlbumArtist;

                    if (newAlbumName != songViewModel.Album.Name || newAlbumAristName != songViewModel.Album.ArtistName)
                    {
                        ArtistViewModel albumArtistViewModel = LibraryViewModel.Current.LookupArtistByName(newAlbumAristName);
                        AlbumViewModel  newAlbumViewModel    = LibraryViewModel.Current.LookupAlbumByName(newAlbumName, albumArtistViewModel.ArtistId);

                        songViewModel.UpdateAlbum(newAlbumViewModel);
                    }

                    songViewModel.TrackNumber = song.TrackNumber;
                }
                return(false);
            }

            SongModel newSongModel = LibraryModel.Current.AddNewSong(
                song.Artist,
                song.Album,
                song.AlbumArtist,
                song.Name,
                song.Source,
                StorageProviderSourceToSongOriginSource(song.Origin),
                song.Duration.Ticks,
                song.Rating,
                song.TrackNumber
                );

            if (LookupSong(newSongModel) == null)
            {
                DebugHelper.Alert(new CallerInfo(), "Failed to add song");
                return(false);
            }

            return(true);
        }
        internal bool AddSong(StorageProviderSong song, bool resetSongData)
        {
            SongModel songFromSource = LibraryModel.Current.GetSongFromSource(StorageProviderSourceToSongOriginSource(song.Origin), song.Source);
            if (songFromSource != null)
            {
                if (resetSongData)
                {
                    SongViewModel songViewModel = LookupSong(songFromSource);

                    songViewModel.Name = song.Name;

                    songViewModel.ArtistName = song.Artist;

                    string newAlbumName = song.Album;
                    string newAlbumAristName = song.AlbumArtist;

                    if (newAlbumName != songViewModel.Album.Name || newAlbumAristName != songViewModel.Album.ArtistName)
                    {
                        ArtistViewModel albumArtistViewModel = LibraryViewModel.Current.LookupArtistByName(newAlbumAristName);
                        AlbumViewModel newAlbumViewModel = LibraryViewModel.Current.LookupAlbumByName(newAlbumName, albumArtistViewModel.ArtistId);

                        songViewModel.UpdateAlbum(newAlbumViewModel);
                    }

                    songViewModel.TrackNumber = song.TrackNumber;
                }
                return false;
            }

            SongModel newSongModel = LibraryModel.Current.AddNewSong(
                song.Artist,
                song.Album,
                song.AlbumArtist,
                song.Name,
                song.Source,
                StorageProviderSourceToSongOriginSource(song.Origin),
                song.Duration.Ticks,
                song.Rating,
                song.TrackNumber
                );

            if (LookupSong(newSongModel) == null)
            {
                DebugHelper.Alert(new CallerInfo(), "Failed to add song");
                return false;
            }

            return true;
        }