BookController

BookController handle with Book Resource Api. Pass a Chapter Object Model(\Models\BookModel) to the constructor of parent class (\Controller\BaseController) for it map the basic database crud operations to this Object.

Extends

Methods

inner getStudentBooks(books) → {json}

Get student books from books ID list
Parameters:
Name Type Description
books array
Returns:
json - status and return array list of full books.

inner RemoveBook(req, res) → {json}

RemoveBook Method. Responds to DELETE /book/:id. Delete book by its ID and remove itself from user book list. If Success returns 200 status code and a json with the deleted book. If error return 400 status code and a json => { errors }. 500 status code only will be returned if the method generates some unexpected error.
Parameters:
Name Type Description
req object Express requisition object.
res object Express response object.
Returns:
json - status and return object.
To Do:
  • Write comments

inner removeChapterFromList(bookId, chapterId)

Get book chapters and filter through passed chapter ID
Parameters:
Name Type Description
bookId Long
chapterId Long

inner saveBook(req, res) → {json}

Book Save Method. Responds to POST /book. Saves the book with student ID, and then add book to student books list. If Success returns 200 status code and a json with this.Book saved data. If error return 400 status code and a json => { errors }. 500 status code only will be returned if the method generates some unexpected error.
Parameters:
Name Type Description
req object Express requisition object.
res object Express response object.
Returns:
json - status and return object.