public IActionResult Insert([FromBody] SolrBook book) { var dbBook = new Book(); book.SaveToModel(Context, dbBook); Context.Books.Add(dbBook); Context.SaveChanges(); SolrService.IndexBook(dbBook); return(Ok(SolrBook.FromBook(dbBook))); }
public IActionResult Update([FromBody] SolrBook book) { var dbBook = Context.Books.SingleOrDefault(m => m.Id == book.id); if (dbBook == null) { return(NotFound(new { message = $"Book with id {book.id} was not found" })); } book.SaveToModel(Context, dbBook); Context.Books.Update(dbBook); Context.SaveChanges(); SolrService.IndexBook(dbBook); return(Ok(SolrBook.FromBook(dbBook))); }