public JsonResult Create(FormCollection collection) { var b = new Book(); if (TryUpdateModel(b)) { bookRepository.Insert(b); if (bookRepository.Commit()) { return Json(b); } } return Json(b); }
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); }
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; }); }
public ActionResult Create() { var b = new Book(); UpdateLists(b); return View(b); }
private void UpdateLists(Book _book) { ViewBag.Authors = authorRepository().GetAll().ToDropDown(c => c.ID.ToString(), c => c.FullName, c => _book.AuthorID == c.ID); }
public static void Send(Book book) { Messenger.Default.Send(book, MessageTypes.EditBook); }