public JsonResult Add()
        {
            var book = new Libro
            {

                Titulo = "New book",
                Autor = "Unknown",
                Año = DateTime.Now.Year
            };
            Library.AddBook(book);
            return Json(Library.GetBooks(),
              JsonRequestBehavior.AllowGet);
        }
Beispiel #2
0
 public bool UpdateBook(Libro book)
 {
     var index = books.FindIndex(b => b.ID == book.ID);
     if (index == -1)
         return false;
     books.RemoveAt(index);
     books.Insert(index, book);
     return true;
 }
Beispiel #3
0
 public void AddBook(Libro book)
 {
     book.ID = nextId++;
     books.Add(book);
 }
 public ActionResult Edit(Libro book)
 {
     Library.UpdateBook(book);
     return RedirectToAction("Index");
 }