Esempio n. 1
0
 public JsonResult Create(FormCollection collection)
 {
     var b = new Book();
     if (TryUpdateModel(b))
     {
         bookRepository.Insert(b);
         if (bookRepository.Commit())
         {
             return Json(b);
         }
     }
     return Json(b);
 }
Esempio n. 2
0
 public ActionResult Create(FormCollection collection)
 {
     var b = new Book();
     if (TryUpdateModel(b))
     {
         bookRepository.Insert(b);
         if (bookRepository.Commit())
         {
             return RedirectToAction("Index");
         }
         ModelState.AddModelError("db", bookRepository.Errors);
     }
     return RedirectToAction("Create", b);
 }
Esempio n. 3
0
 public BookViewModel(Func<IBookRepository> _bookRepo, IBusy status)
 {
     bookRepo = _bookRepo;
     Status = status;
     Status.Busy = true;
     Messenger.Default.Register<string>(this, "menuaction", d =>
         {
             if (d == "New book")
                 selected = new Book();
             Messenger.Default.Send(d, "DialogBook");
         });
     Task.Factory.StartNew(() =>
         {
             Books = bookRepo().GetAll().ToObservable();
             Status.Busy = false;
         });
 }
Esempio n. 4
0
 public ActionResult Create()
 {
     var b = new Book();
     UpdateLists(b);
     return View(b);
 }
Esempio n. 5
0
 private void UpdateLists(Book _book)
 {
     ViewBag.Authors = authorRepository().GetAll().ToDropDown(c => c.ID.ToString(), c => c.FullName, c => _book.AuthorID == c.ID);
 }
Esempio n. 6
0
 public static void Send(Book book)
 {
     Messenger.Default.Send(book, MessageTypes.EditBook);
 }