public static Book ToModel(this BookResource resource, Book book) { var updatedBook = resource.ToModel(); book.ApplyChanges(updatedBook); book.Editions = updatedBook.Editions; return(book); }
private void UpdateBook(BookResource bookResource) { var book = _bookService.GetBook(bookResource.Id); var model = bookResource.ToModel(book); _bookService.UpdateBook(model); _editionService.UpdateMany(model.Editions.Value); BroadcastResourceChange(ModelAction.Updated, model.Id); }
public ActionResult <BookResource> UpdateBook(BookResource bookResource) { var book = _bookService.GetBook(bookResource.Id); var model = bookResource.ToModel(book); _bookService.UpdateBook(model); _editionService.UpdateMany(model.Editions.Value); BroadcastResourceChange(ModelAction.Updated, model.Id); return(Accepted(model.Id)); }
public ActionResult <BookResource> AddBook(BookResource bookResource) { var book = _addBookService.AddBook(bookResource.ToModel()); return(Created(book.Id)); }
private int AddBook(BookResource bookResource) { var book = _addBookService.AddBook(bookResource.ToModel()); return(book.Id); }