public Book UpdateBookById(int bookId, BookWithAuthorsVM book) { var _book = _context.Books.FirstOrDefault(b => b.Id == bookId); if (_book != null) { _book.Title = book.Title; _book.Description = book.Description; _book.IsRead = book.IsRead; _book.DateRead = book.IsRead ? book.DateRead.Value : null; _book.Rate = book.Rate; _book.Genre = book.Genre; // _book.Author = book.Author; _book.CoverUrl = book.CoverUrl; } _context.SaveChanges(); return(_book); }
public IActionResult UpdateBookById(int id, [FromBody] BookWithAuthorsVM book) { var updatedBook = _booksService.UpdateBookById(id, book); return(Ok(updatedBook)); }