public ActionResult Create(AdminBaseViewModel <AdminUser> model, int[] userRoles) { var user = model.Item; // ensure the email address is unique if (!_repo.IsEmailUnique(user.EmailAddress)) { ModelState.AddModelError("NonUnique", "The email address is not unique"); } HandlePassword(user, true); if (!ModelState.IsValid) { return(View("Edit", new AdminBaseViewModel <AdminUser> { Item = user })); } try { // handle roles AddUpdateRoles(user, userRoles); _repo.Add(user); _uow.Commit(); CreatedItem(); SetListPage(Url.Action("Index")); return(RedirectToAction("Edit", new { id = user.ID })); } catch (Exception ex) { RaiseError(ex); return(View("Edit", new AdminBaseViewModel <AdminUser> { Item = user })); } }