Пример #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 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);
 }
Пример #3
0
 public ActionResult Edit(BookModel book)
 {
     Library.UpdateBook(book);
     return RedirectToAction("Index");
 }
Пример #4
0
 public void AddBook(BookModel book)
 {
     book.Id = NextId++;
       Books.Add(book);
 }