public ActionResult Create(User user) { var createdUser = _iFUser.Create(UserId, user); _iFUserRole.Create(UserId, createdUser.UserId, user.UserRoles); return(RedirectToAction("Index")); }
public JsonResult AddUser(User user, List <Role> roles) { try { user = _iFUser.Create(user); _iFUserRole.Create(roles, user.UserId); } catch (Exception ex) { return(Json(ex.ToString())); } return(Json(string.Empty)); }
public ActionResult Create(User user) { try { var createdUser = _iFUser.Create(UserId, user); _iFUserRole.Create(UserId, createdUser.UserId, user.UserRoles); if (ModelState.IsValid) { TempData["message"] = "User has been created, successfully!"; } return(RedirectToAction("Create")); } catch (Exception) { if (ModelState.IsValid) { // Do your stuff TempData["message"] = "Opps! Something went wrong. Please, try again."; } return(RedirectToAction("Create")); } }