public ActionResult IdentityProfileSettings() { MVC5_TemplateIdentityUser MVC5_TemplateUser = _UserManager.FindById(User.Identity.GetUserId()); IdentityProfileViewModel profileViewModel = new IdentityProfileViewModel() { CurrentEmail = MVC5_TemplateUser.Email, }; return(View(profileViewModel)); }
/// <summary> /// Method updates all user properties (It doesn't update password !) /// </summary> /// <param name="profileViewModel"></param> public async Task <IdentityResult> UpdateUser(IdentityProfileViewModel profileViewModel) { OntoIdentityUser ontoIdentityUser = this.FindById(HttpContext.Current.User.Identity.GetUserId()); ontoIdentityUser.Email = profileViewModel.NewEmail == null ? profileViewModel.CurrentEmail : profileViewModel.NewEmail; ontoIdentityUser.UserName = profileViewModel.NewEmail == null ? profileViewModel.CurrentEmail : profileViewModel.NewEmail; IdentityResult result = await this.UpdateAsync(ontoIdentityUser); return(result); }
public async Task <ActionResult> IdentityProfileSettings(IdentityProfileViewModel identityProfileViewModel) { if (ModelState.IsValid == false) { return(View(identityProfileViewModel)); } IdentityResult identityResult = await _UserManager.UpdateUser(identityProfileViewModel); if (identityResult.Succeeded == false) { _UserSettingsLogic.AddErrors(ModelState, identityResult); } return(RedirectToAction("IdentityProfileSettings")); }