예제 #1
0
 public ActionResult Create(Book book)
 {
     if (book != null)
     {
         book.Id = ++BookProvider.Counter;
         BookProvider.Instance.AllBooks.Add(book);
     }
     return View("BookList", BookProvider.Instance.AllBooks);
 }
예제 #2
0
 static BookProvider()
 {
     Instance = new BookProvider();
     Instance.AllBooks = new List<Book>();
     for (int i = 1; i <= 10 ; i++)
     {
         Counter++;
         Book book = new Book() { Id = i, Name = String.Format("Book #{0}", i), Price = i };
         Instance.AllBooks.Add(book);
     }
 }
예제 #3
0
 public ActionResult Edit(Book book)
 {
     if (book != null)
     {
         Book editingBook = BookProvider.Instance.AllBooks.SingleOrDefault(b => b.Id == book.Id);
         if (editingBook != null)
         {
             editingBook.Name = book.Name;
             editingBook.Price = book.Price;
         }
     }
     return View("BookList", BookProvider.Instance.AllBooks);
 }