public ActionResult UpdateInfoPost(EditUserModel editUserModel) { try { // TODO: Add update logic here if (ModelState.IsValid) { User user = UserHelpers.GetCurrentUser(Session); if (user == null) { ModelState.AddModelError("", "You are signed out!Please signin to do this!"); return RedirectToAction("EditProfile"); } user.UserFirstName = editUserModel.UserFirstName; user.UserLastName = editUserModel.UserLastName; user.UserDOB = editUserModel.UserDOB; user.IDCard = editUserModel.IDCard; user.Gender = editUserModel.Gender; user.Phone = editUserModel.Phone; user.Place = editUserModel.Place; if (UserDatabaseHelper.Instance.UpdateUser(user)) { UserHelpers.SetCurrentUser(Session, user); return RedirectToAction("Index"); } else { ModelState.AddModelError("", "Something went wrong! Please try again!"); return RedirectToAction("EditProfile"); } } ModelState.AddModelError("", "Something went wrong! Please try again!"); return RedirectToAction("EditProfile"); } catch (Exception ex) { TempData["ManageProfileTask"] = "EditProfile"; ModelState.AddModelError("", "Something went wrong! Please try again!"); return RedirectToAction("EditProfile"); } }
public ActionResult UpdateInfo() { User userSession = UserHelpers.GetCurrentUser(Session); if (userSession == null) { TempData["errorTitle"] = "Require Signin"; TempData["errorMessage"] = "Ops.. It look like you are current is not signed in system! Please sign in first!"; return RedirectToAction("Index", "Home"); } EditUserModel editUserModel = new EditUserModel(); editUserModel.UserID = userSession.UserID; editUserModel.UserDOB = userSession.UserDOB; editUserModel.UserFirstName = userSession.UserFirstName; editUserModel.UserLastName = userSession.UserLastName; editUserModel.Phone = userSession.Phone; editUserModel.Place = userSession.Place; editUserModel.IDCard = userSession.IDCard; return PartialView(editUserModel); }