Пример #1
0
        public IObservable <Library> CancelDownloadsFromLibrary(Library library)
        {
            var downloadsInLibrary = LoggedUser.Downloads.Where(download => download.LibraryId == library.ServerId).ToList();

            LoggedUser.Downloads.Remove(downloadsInLibrary);

            return(DownloadManager.CancelDownloads(downloadsInLibrary)
                   .FinishedToNext()
                   .Select(_ => library));
        }
Пример #2
0
        public void DeleteMediaItem(MediaItemsListModelItem item)
        {
            var downloads = LoggedUser.Downloads.Where(dl => dl.Id == item.Id).ToList();

            if (downloads.Count > 0)
            {
                DownloadManager.CancelDownloads(downloads)
                .ObserveOnDispatcher()
                .Finally(() =>
                {
                    using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        foreach (var download in downloads)
                        {
                            string path = Utils.MediaFilePath(LoggedUser, download);
                            if (isf.FileExists(path))
                            {
                                isf.DeleteFile(path);
                            }
                        }
                    }
                })
                .Subscribe();

                LoggedUser.Downloads.Remove(downloads);
            }
            else
            {
                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    string path = Utils.MediaFilePath(LoggedUser, item);
                    if (isf.FileExists(path))
                    {
                        isf.DeleteFile(path);
                    }
                }
            }
        }