public ActionResult CreateUser(UserViewModel userInfo) { ActionResult response = null; try { if (Session["UserName"] == null) { UserPO form = userInfo.Form; if (ModelState.IsValid) { UserMap map = new UserMap(); UserDO userObject = map.UserPOToDO(form); userObject.RoleID = 1; userDL.CreateUser(userObject); response = RedirectToAction("Login", "Account"); } else { response = View(userInfo); } } else { response = RedirectToAction("Index", "Home"); } } catch (SqlException sqlEx) { //What about the exception do we wish to analyze? userInfo.message = new ExceptionAnalysis().GenerateResponse(sqlEx); response = View(userInfo); } return(response); }
public ActionResult UpdateUser(UserViewModel userInfo) { ActionResult response = null; try { if ((Int64)Session["RoleID"] == 3) { UserPO form = userInfo.Form; UserMap map = new UserMap(); if (ModelState.IsValid) { UserDO userObject = map.UserPOToDO(form); userDL.UpdateUser(userObject); response = RedirectToAction("UserIndex"); } else { response = View(userInfo); } } else { response = RedirectToAction("Index", "Home"); } } catch (SqlException sqlEx) { userInfo.message = new ExceptionAnalysis().GenerateResponse(sqlEx); response = View(userInfo); } return(response); }