Example #1
0
        public ActionResult IdentityProfileSettings()
        {
            MVC5_TemplateIdentityUser MVC5_TemplateUser = _UserManager.FindById(User.Identity.GetUserId());

            IdentityProfileViewModel profileViewModel = new IdentityProfileViewModel()
            {
                CurrentEmail = MVC5_TemplateUser.Email,
            };

            return(View(profileViewModel));
        }
Example #2
0
        /// <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);
        }
Example #3
0
        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"));
        }