public ActionResult UpdateProfile(UpdateProfileModel model) { if (ModelState.IsValid) { var userEntity = GetUserEntity(model); var status = _userRepository.UpdateProfile(userEntity); if (!status) { ModelState.AddModelError("__FORM", "Unable to update the profile. Please try again later or contact the administrator"); } else { model.UpdateStatus = true; } } model.Title = SettingsRepository.BlogName; return View(model); }
private UserEntity GetUserEntity(UpdateProfileModel model) { var userEntity = new UserEntity { UserID = GetUserId(), UserDisplayName = model.UserDisplayName, UserEmailAddress = model.UserEmailAddress, UserSite = model.UserSite }; if (!string.IsNullOrEmpty(model.NewPassword) && !string.IsNullOrEmpty(model.ConfirmPassword)) { var randomCode = RandomStringGenerator.RandomString(); userEntity.Password = PasswordHelper.GenerateHashedPassword(model.NewPassword, randomCode); userEntity.UserCode = TripleDES.EncryptString(randomCode); } return userEntity; }
public ActionResult UpdateProfile() { var userEntity = _userRepository.GetUserObjByUserID(GetUserId()); var model = new UpdateProfileModel { UserDisplayName = userEntity.UserDisplayName, UserEmailAddress = userEntity.UserEmailAddress, Title = SettingsRepository.BlogName, UserSite = userEntity.UserSite }; return View(model); }