public ActionResult Create(VMBorrower data) { try { // context on outside because both sides of modelstate // need context (then needs to update, and else needs to repopulate) using (Context ctx = new Context()) { if (ModelState.IsValid) { ctx.BorrowerCreate(data); return(RedirectToAction("Index")); } else { data.PopulateRoleItems(ctx.RoleGetAll()); return(View(data)); } } } catch (Exception ex) { return(View("Exception", ex)); } }
// GET: Borrower/Create public ActionResult Create() { try { using (Context ctx = new Context()) { var data = new VMBorrower(); data.PopulateRoleItems(ctx.RoleGetAll()); return(View(data)); } } catch (Exception ex) { return(View("Exception", ex)); } }