コード例 #1
0
        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)));
        }
コード例 #2
0
        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)));
        }