public ActionResult UpdateAccountInfo(UpdateAccountInfoViewModel viewmodel)
 {
     //var viewmodel = new RegisterViewModel();
     if (viewmodel.Password != null && viewmodel.ConfirmPassword != null)
     {
         BoardSquaresRepository.AttemptPasswordChange(viewmodel.UserID, viewmodel.Password);
     }
     BoardSquaresRepository.AttemptUpdateWeeklyEmails(viewmodel.UserID, viewmodel.WeeklyUpdates);
     //var test = true;
     return(View(viewmodel));
 }
示例#2
0
        public ActionResult UpdateAccountInfo(UpdateAccountInfoViewModel viewmodel)
        {
            var didTryPasswordChange  = false;
            var passwordChangeSuccess = false;

            if (viewmodel.Password != null && viewmodel.ConfirmPassword != null)
            {
                didTryPasswordChange = true;
                var result = BoardSquaresRepository.AttemptPasswordChange(viewmodel.UserID, viewmodel.Password);

                passwordChangeSuccess = result == 1;
            }

            BoardSquaresRepository.AttemptUpdateWeeklyEmails(viewmodel.UserID, viewmodel.WeeklyUpdates);

            if (didTryPasswordChange)
            {
                if (passwordChangeSuccess)
                {
                    ViewBag.UpdateAccountInfoMessage   = "Your password and settings have been successfully updated!";
                    ViewBag.UpdateAccountInfoIsSuccess = true;
                }
                else
                {
                    ViewBag.UpdateAccountInfoMessage   = "We were unable to change your password at this time.";
                    ViewBag.UpdateAccountInfoIsSuccess = false;
                }
            }
            else
            {
                ViewBag.UpdateAccountInfoMessage   = "Your settings have been successfully updated!";
                ViewBag.UpdateAccountInfoIsSuccess = true;
            }

            return(View(viewmodel));
        }