Ejemplo n.º 1
0
 public void IndexBook(Book book)
 {
     RestCall(BuildApiUrl(collection, "update", "json", "docs"), Method.POST, rq =>
     {
         rq.AddQueryParameter("commit", "true");
         rq.AddJsonBody(SolrBook.FromBook(book));
     });
 }
Ejemplo n.º 2
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)));
        }
Ejemplo n.º 3
0
        public IActionResult GetBook(Guid id)
        {
            var book = Context.Books
                       .Include(m => m.Author)
                       .SingleOrDefault(m => m.Id == id);

            if (book == null)
            {
                return(NotFound(new { message = $"Book with id {id} was not found" }));
            }
            return(Ok(SolrBook.FromBook(book)));
        }
Ejemplo n.º 4
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)));
        }