public bool DeleteBook(Book.Book book) //, BookCollection collection) { Debug.Assert(book == _bookSelection.CurrentSelection); if (_bookSelection.CurrentSelection != null && _bookSelection.CurrentSelection.CanDelete) { if (IsCurrentBookInCollection()) { if (!_tcManager.CanEditBook()) { var msg = LocalizationManager.GetString("TeamCollection.CheckOutForDelete", "Please check out the book before deleting it."); ErrorReport.NotifyUserOfProblem(msg); return(false); } if (_tcManager.CannotDeleteBecauseDisconnected(_bookSelection.CurrentSelection.FolderPath)) { var msg = LocalizationManager.GetString("TeamCollection.ConnectForDelete", "Please connect to the Team Collection before deleting books that are part of it."); ErrorReport.NotifyUserOfProblem(msg); return(false); } } var title = _bookSelection.CurrentSelection.TitleBestForUserDisplay; var confirmRecycleDescription = L10NSharp.LocalizationManager.GetString("CollectionTab.ConfirmRecycleDescription", "The book '{0}'"); if (ConfirmRecycleDialog.JustConfirm(string.Format(confirmRecycleDescription, title), false, "Palaso")) { // The sequence of these is a bit arbitrary. We'd like to delete the book in both places. // Either could conceivably fail. If something goes wrong with removing the selection // from it (very unlikely), we may as well leave nothing changed. If we delete it from // the local collection but fail to delete it from the repo, it will come back at the // next startup. If we delete it from the repo but fail to delete it locally, // it will just stick around, and at least the desired team collection result has // been achieved and the local result won't be a surprise later. So it seems marginally // better to do them in this order. _bookSelection.SelectBook(null); _tcManager.CurrentCollection?.DeleteBookFromRepo(book.FolderPath); TheOneEditableCollection.DeleteBook(book.BookInfo); #if Chorus _sendReceiver.CheckInNow(string.Format("Deleted '{0}'", title)); #endif return(true); } } return(false); }
public bool DeleteBook(Book.Book book) //, BookCollection collection) { Debug.Assert(book == _bookSelection.CurrentSelection); if (_bookSelection.CurrentSelection != null && _bookSelection.CurrentSelection.CanDelete) { var title = _bookSelection.CurrentSelection.TitleBestForUserDisplay; var confirmRecycleDescription = L10NSharp.LocalizationManager.GetString("CollectionTab.ConfirmRecycleDescription", "The book '{0}'"); if (ConfirmRecycleDialog.JustConfirm(string.Format(confirmRecycleDescription, title), false, "Palaso")) { TheOneEditableCollection.DeleteBook(book.BookInfo); _bookSelection.SelectBook(null); _sendReceiver.CheckInNow(string.Format("Deleted '{0}'", title)); return(true); } } return(false); }