Exemplo n.º 1
0
        public ActionResult ChangeEmail(ChangeEmailViewModel model, string email)
        {
            //checks if email already exists in the system
            var _email = accountDAO.FetchByEmail(email);

            if (_email == null)
            {
                emails.SendChangedEmailAddressVerificationEmail(model.email, model.email);
                TempData["successMessage"] = "A confirmation has been sent to your email. Your email will be changed once you follow the link in your email";
                return(RedirectToAction("ChangeEmail", "Account"));
            }

            //prevents user from changing their email to email that already exists in the system
            else if (_email != null)
            {
                TempData["errorMessage"] = "That email already exists in the system";
                return(RedirectToAction("ChangeEmail", "Account"));
            }

            return(View(model));
        }