private async Task <bool> delete(LibraryItem item) { if (item == null || item.Storage == LibraryItemStorage.iTunes) { return(false); } LoggerService.Instance.Log("INFO: Library.delete: ID: " + item.ID); if (item.IsLocal) { if (item.Storage == LibraryItemStorage.AppLocal) { var deleted = LocalLibraryService.Instance.DeleteMediaItem(item, true); if (deleted) { if (CloudItems != null) { var deletedItem = CloudItems.FirstOrDefault(cloudItem => item.ID == cloudItem.ID); if (deletedItem != null) { deletedItem.DownloadStatus = DownloadStatus.Unknown; deletedItem.LocalItem = null; } } if (LocalItems != null) { LocalItems.Remove(item); OnPropertyChanged(nameof(LocalItemsCount)); } if (item.Equals(SelectedItem)) { SelectedItem = null; } if (item.Equals(SelectedLibraryItem)) { SelectedLibraryItem = null; } return(true); } } } else { var response = await LibraryClient.Delete(item.ID); if (response != null && response.Success) { if (Account != null && Account.SignedIn && Account.UserInfo != null && !string.IsNullOrEmpty(Account.UserInfo.Email)) { LocalLibraryService.Instance.DeleteCloudItemId(item.ID, Account.UserInfo.Email); } CloudItems.Remove(item); OnPropertyChanged(nameof(CloudItemsCount)); if (item.Equals(SelectedItem)) { SelectedItem = null; } if (item.Equals(SelectedCloudItem)) { SelectedCloudItem = null; } return(true); } } return(false); }