Exemple #1
0
        public async Task<ActionResult> ChangeEmail(ChangeUserEmailViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                IdentityResult result = await this.UserManager.SetEmailAsync(user.Id, model.Email);
                if (result.Succeeded)
                {
                   
                    SendEmailComfirmation();
                    if (ModelState.IsValid)
                    {
                        TempData["toastrMessage"] = String.Format("Email успешно изменен, на почту выслан запрос на подтверждение");
                        TempData["toastrType"] = "success";
                    }
                    return View();
                }
                else {
                    AddErrors(result);
                }
            }
            return View();
        }
Exemple #2
0
 public async Task<ActionResult> ChangeEmail()
 {
     ChangeUserEmailViewModel result = new ChangeUserEmailViewModel();
     var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
     if (user != null)
     {
         result.Email = user.Email;
         result.EmailConfirmed = user.EmailConfirmed;
     }
     return View(result);
 }