private async Task DeleteTracksFromPlaylistsAsync()
        {
            DeleteTracksFromPlaylistsResult result = await this.collectionService.DeleteTracksFromPlaylistAsync(this.SelectedTracks, this.SelectedPlaylists.FirstOrDefault());

            switch (result)
            {
            case DeleteTracksFromPlaylistsResult.Success:
                await this.GetTracksAsync(this.SelectedPlaylists, this.TrackOrder);

                break;

            case DeleteTracksFromPlaylistsResult.Error:
                this.dialogService.ShowNotification(
                    0xe711,
                    16,
                    ResourceUtils.GetStringResource("Language_Error"),
                    ResourceUtils.GetStringResource("Language_Error_Removing_From_Playlist"),
                    ResourceUtils.GetStringResource("Language_Ok"),
                    true,
                    ResourceUtils.GetStringResource("Language_Log_File"));
                break;

            default:
                break;
                // Never happens
            }
        }
Esempio n. 2
0
        public async Task <DeleteTracksFromPlaylistsResult> DeleteTracksFromPlaylistAsync(IList <TrackInfo> tracks, Playlist selectedPlaylist)
        {
            DeleteTracksFromPlaylistsResult result = await this.playlistRepository.DeleteTracksFromPlaylistAsync(tracks, selectedPlaylist);

            if (result == DeleteTracksFromPlaylistsResult.Success)
            {
                this.DeletedTracksFromPlaylists(this, new EventArgs());
            }

            return(result);
        }
Esempio n. 3
0
        public async Task <DeleteTracksFromPlaylistsResult> DeleteTracksFromPlaylistAsync(IList <TrackInfo> tracks, Playlist selectedPlaylist)
        {
            DeleteTracksFromPlaylistsResult result = DeleteTracksFromPlaylistsResult.Success;

            await Task.Run(() =>
            {
                try
                {
                    using (var conn = this.factory.GetConnection())
                    {
                        if (tracks != null)
                        {
                            foreach (TrackInfo ti in tracks)
                            {
                                try
                                {
                                    PlaylistEntry playlistEntryToDelete = conn.Table <PlaylistEntry>().Select((p) => p).Where((p) => p.TrackID.Equals(ti.TrackID) & p.PlaylistID.Equals(selectedPlaylist.PlaylistID)).FirstOrDefault();
                                    conn.Delete(playlistEntryToDelete);
                                }
                                catch (Exception ex)
                                {
                                    LogClient.Instance.Logger.Error("An error occured while deleting PlaylistEntry for Track '{0}'. Exception: {1}", ti.Path, ex.Message);
                                    result = DeleteTracksFromPlaylistsResult.Error;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogClient.Instance.Logger.Error("Could not connect to the database. Exception: {0}", ex.Message);
                }
            });

            return(result);
        }