private IActionResult createBook(BookView bookView)
        {
            Book book      = bookViewToBook(bookView);
            Book savedBook = _bookRepository.Create(book);

            return(new ObjectResult(bookToBookView(savedBook)));
        }
        private Book bookViewToBook(BookView bookView)
        {
            Book dbBook = new Book();

            dbBook.Author = bookView.Author;
            dbBook.Title  = bookView.Title;
            dbBook.Isbn   = bookView.Isbn;

            return(dbBook);
        }
 public IActionResult Put(string id, [FromBody] BookView bookView)
 {
     if (ModelState.IsValid)
     {
         return(updateBook(id, bookView));
     }
     else
     {
         return(handleModelStateError());
     }
 }
 public IActionResult Post([FromBody] BookView bookView)
 {
     if (ModelState.IsValid)
     {
         return(createBook(bookView));
     }
     else
     {
         return(handleModelStateError());
     }
 }
        private BookView bookToBookView(Book dbBook)
        {
            BookView bookView = new BookView();

            bookView.Id     = dbBook.Id.ToString();
            bookView.Author = dbBook.Author;
            bookView.Title  = dbBook.Title;
            bookView.Isbn   = dbBook.Isbn;

            return(bookView);
        }
 private IActionResult updateBook(string id, BookView bookView)
 {
     if (bookExists(id))
     {
         Book book      = bookViewToBook(bookView);
         Book savedBook = _bookRepository.Update(id, book);
         return(new ObjectResult(bookToBookView(savedBook)));
     }
     else
     {
         return(NotFound());
     }
 }