public ActionResult Create(NewBookEntry newBook) { if (ModelState.IsValid) { db.NewBookEntries.Add(newBook); db.SaveChanges(); if (User.IsInRole("Admin")) { return RedirectToAction("Index"); } else { return RedirectToAction("MyBooks"); } } else return View(newBook); }
public ActionResult Edit(int id,NewBookEntry bookcondition) { try { var book = db.NewBookEntries.Find(id); UpdateModel(book); db.SaveChanges(); if (User.IsInRole("Admin")) { return RedirectToAction("Index"); } else { return RedirectToAction("MyBooks"); } } catch { ModelState.AddModelError("", "Edit Failure, see inner exception"); return View(); } }