def create(self, book: Book): """ Wrapper method for Model :param book: Book :return: None """ create_book = self.model.create_one(book.get_dict()) if not create_book: return create_book
def update_details(self, book_id: str, new_book_details: dict): """ Push Update book Information to Mongo :param book_id: :param new_book_details: :return: response: dict {flash_message, book_title} """ response = {"flash_message": "", "book_title": ""} book = Book(new_book_details) create_book = self.update(ObjectId(book_id), book.get_dict()) if create_book is not None: response['flash_message'] = "Could Not Add book, Try Again" else: response[ 'flash_message'] = f'{book.get_formatted_title()} updated!' response['book_url_title'] = book.get_title_for_url() return response