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); }
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; }
public void AddBook(Libro book) { book.ID = nextId++; books.Add(book); }
public ActionResult Edit(Libro book) { Library.UpdateBook(book); return RedirectToAction("Index"); }