示例#1
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);
 }
示例#2
0
 static LibraryController()
 {
     var model = new LibraryModel
     {
         Name = "My home library",
         Books = new List<BookModel>(),
         NextId = 1
     };
     model.AddBook(new BookModel { Title = "Oliver Twist", Author = "Charles Dickens", Year = 1837 });
     model.AddBook(new BookModel { Title = "Winnie-the-Pooh", Author = "A. A. Milne", Year = 1926 });
     model.AddBook(new BookModel { Title = "The Hobbit", Author = "J. R. R. Tolkien", Year = 1937 });
     model.AddBook(new BookModel { Title = "The Bicentennial Man", Author = "Isaac Asimov", Year = 1976 });
     model.AddBook(new BookModel { Title = "The Green Mile", Author = "Stephen King", Year = 1996 });
     Library = model;
 }
示例#3
0
 public ActionResult Remove(LibraryModel clientLibrary, int index)
 {
     clientLibrary.Books.RemoveAt(index);
     Library = clientLibrary;
     return Json(clientLibrary);
 }
示例#4
0
 public ActionResult EditRedirect(LibraryModel clientLibrary, int index)
 {
     Library = clientLibrary;
     return Json(new { redirect = true, url = "Library/Edit?index=" + index });
 }