Exemplo n.º 1
0
        public ActionResult ChangeEmail(ChangeEmailViewModel model)
        {
            if (ModelState.IsValid)
            {
                string email = model.Email;
                string userName = Membership.GetUserNameByEmail(email);

                // checks if there is a duplicate email in the database
                if (userName == null || (userName == User.Identity.Name && userName != null))
                {
                    UpdateProfileEmailInAllLocations(email);
                    return RedirectToAction("Profile");
                }

                return RedirectToAction("failed");

                // don't allow email change as that email is already in use
            }

            return View(model);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Changes logged-in user's email
 /// </summary>
 /// <returns>
 /// ChangeEmailViewModel with current user's email.
 /// </returns>
 public ActionResult ChangeEmail()
 {
     MembershipUser u = Membership.GetUser(User.Identity.Name);
     ViewBag.Email1 = u.Email;
     var model = new ChangeEmailViewModel {Email = u.Email};
     return View(model);
 }