Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public ActionResult Add(LibraryModel clientLibrary)
 {
     var book = new BookModel
     {
         Title = "New book",
         Author = "Unknown",
         Year = DateTime.Now.Year
     };
     clientLibrary.AddBook(book);
     Library = clientLibrary;
     return Json(clientLibrary);
 }
Ejemplo n.º 3
0
 public ActionResult Edit(BookModel book)
 {
     Library.UpdateBook(book);
     return RedirectToAction("Index");
 }
Ejemplo n.º 4
0
 public void AddBook(BookModel book)
 {
     book.Id = NextId++;
       Books.Add(book);
 }