public Task<IIndexResponse> AddBookAsync(Book bk) { var tIndexBook = Task.Factory.StartNew(() => { return esClient.Index(bk, i=>i.Index(C_INDEXNAME) .Type(C_BOKTYPENAME) .Id(bk.Id)); }); return tIndexBook; }
/// <summary> /// This API will return true if the book was created /// and false if an existing book was updated /// </summary> /// <param name="bk"></param> /// <returns></returns> public Boolean AddBook(Book bk) { try { var result = AddBookAsync(bk).Result; return result.Created; } catch (Exception ex) { throw new ApplicationException(String.Format("Error indexing book : {0}", ex.Message)); } }
public ActionResult Create(Book bk) { try { // TODO: Add insert logic here if(_repo.AddBook(bk)) return RedirectToAction("Index"); return View(); } catch { return View(); } }
public Boolean EditBook(int BookId, Book bk) { var status = esClient.Index(bk, i => i.Index(C_INDEXNAME) .Type(C_BOKTYPENAME) .Id(BookId)); return true; }
public ActionResult Edit(int id, Book bk) { try { // TODO: Add update logic here if(_repo.EditBook(id, bk)) return RedirectToAction("Index"); return View(); } catch { return View(); } }