Bloom.CollectionTab.LibraryModel.DeleteBook C# (CSharp) Method

DeleteBook() public method

public DeleteBook ( Book book ) : bool
book Bloom.Book.Book
return bool
        public bool DeleteBook(Book.Book book)
        {
            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);
                    #if Chorus
                    _sendReceiver.CheckInNow(string.Format("Deleted '{0}'", title));
                    #endif
                    return true;
                }
            }
            return false;
        }

Usage Example

        private void deleteMenuItem_Click(object sender, EventArgs e)
        {
            var button = AllBookButtons().FirstOrDefault(b => b.Tag == SelectedBook.BookInfo);

            if (_model.DeleteBook(SelectedBook))
            {
                Debug.Assert(button != null && _primaryCollectionFlow.Controls.Contains(button));
                if (button != null && _primaryCollectionFlow.Controls.Contains(button))
                {
                    _primaryCollectionFlow.Controls.Remove(button);
                }
            }
        }