예제 #1
0
 public bool UpdateBook(BookModel book)
 {
     var index = books.FindIndex(b => b.Id == book.Id);
       if (index == -1)
     return false;
       books.RemoveAt(index);
       books.Insert(index, book);
       return true;
 }
예제 #2
0
 public JsonResult Add()
 {
     var book = new BookModel
       {
     Title = "New book",
     Author = "Unknown",
     Year = DateTime.Now.Year
       };
       Library.AddBook(book);
       return Json(Library.GetBooks(), JsonRequestBehavior.AllowGet);
 }
예제 #3
0
 public void AddBook(BookModel book)
 {
     book.Id = nextId++;
       books.Add(book);
 }
예제 #4
0
 public ActionResult Edit(BookModel book)
 {
     Library.UpdateBook(book);
       return RedirectToAction("Index");
 }