public static async Task RemoveItem(this StorageLibraryChange change, IEnumerable <Mediafile> Library, LibraryService LibraryService) { if (change.IsOfType(StorageItemTypes.File)) { if (IsItemInLibrary(change, Library, out Mediafile movedItem)) { if (await SharedLogic.RemoveMediafile(movedItem)) { await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("Mediafile Removed. File Path: {0}", movedItem.Path), 5); } } } else { await RemoveFolder(change, (ThreadSafeObservableCollection <Mediafile>) Library, LibraryService); } }
public static async Task AddNewItem(this StorageLibraryChange change) { if (change.IsOfType(StorageItemTypes.File)) { if (await change.GetStorageItemAsync() == null) { return; } if (IsItemPotentialMediafile(await change.GetStorageItemAsync())) { var newFile = await SharedLogic.CreateMediafile((StorageFile)await change.GetStorageItemAsync()); newFile.FolderPath = Path.GetDirectoryName(newFile.Path); if (SharedLogic.AddMediafile(newFile)) { await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("Mediafile Added. File Path: {0}", newFile.Path), 5); } } } }
public static async Task UpdateChangedItem(this StorageLibraryChange change, IEnumerable <Mediafile> Library, LibraryService LibraryService) { if (change.IsOfType(StorageItemTypes.File)) { if (IsItemInLibrary(change, Library, out Mediafile createdItem)) { var id = createdItem.Id; createdItem = await SharedLogic.CreateMediafile((StorageFile)await change.GetStorageItemAsync()); createdItem.Id = id; if (await LibraryService.UpdateMediafile(createdItem)) { await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("Mediafile Updated. File Path: {0}", createdItem.Path), 5); } } else { await AddNewItem(change); } } }