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)); }
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); } } } }