Exemplo n.º 1
0
        public ActionResult ForgotPassword(UserForgotPasswordModel Model, string Action, string ReturnUrl)
        {
            switch (Action.ToUpper())
            {
            case "CANCEL":
                return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, "Login"));

            default:
                break;
            }

            if (!ModelState.IsValid)
            {
                var           allErrors     = ModelState.Values.SelectMany(v => v.Errors);
                List <string> errorMessages = new List <string>();

                string msg = ModelState.First().Value.Errors.First().ErrorMessage.ToString();

                ModelState.AddModelError("", msg);


                return(View("ForgotPassword", Model));
            }

            bool success = _isurveyFacade.UpdateUser(new Enter.Common.DTO.UserDTO()
            {
                UserName = Model.UserName, Operation = Constant.OperationMode.UpdatePassword
            });

            if (success)
            {
                return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, "Login"));
            }
            else
            {
                UserForgotPasswordModel model = new UserForgotPasswordModel();
                model.UserName = Model.UserName;

                ModelState.AddModelError("UserName", "You may have entered an email address that does not match our records. Please try again.");
                return(View("ForgotPassword", model));
            }
        }