Пример #1
0
        public ActionResult EmailManage(EmailManageVm emailManageVm)
        {
            if (ModelState.IsValid)
            {
                var result = Managers.UserAccountManager.UpdateEmailAddress(emailManageVm);

                if (result.Status == StggResultStatus.Failed)
                {
                    ModelState.AddModelSummaryError(result);
                }
            }
            else
            {
                Response.StatusCode = 400;
            }

            return(PartialView("_EmailManage", emailManageVm));
        }
Пример #2
0
        public StggResult <EmailManageVm> GetAccountInfo(int id)
        {
            // Get data from the database and build the result.
            var userProfile         = Repositories.UserProfile.GetOne(x => x.UserId == id, x => x.User);
            var accountInfoEditorVm = new EmailManageVm(userProfile);
            var stggResult          = new StggResult <EmailManageVm>();

            // quick check on returned value.
            if (userProfile == null)
            {
                stggResult.SetStatus(StggResultStatus.Failed);
            }
            else
            {
                // profile was found - return this profile.
                stggResult.SetStatus(StggResultStatus.Succeeded);
                stggResult.SetValue(accountInfoEditorVm);
            }

            // return value
            return(stggResult);
        }
Пример #3
0
        /// <summary>
        /// Update the email address of the user and send the token.
        /// </summary>
        /// <param name="emailManageVm">Email manager view model instance.</param>
        public StggResult UpdateEmailAddress(EmailManageVm emailManageVm)
        {
            var stggResult = new StggResult();

            if (emailManageVm.UserName != CurrentUser.Identity.Name)
            {
                stggResult.AddError("Bad request.");
                return(stggResult);
            }

            // Get the user record from the database.
            var user = AppUserManager.FindById(CurrentUser.Id);

            // Update the email address of the user and save it.
            user.Email          = emailManageVm.Email;
            user.EmailConfirmed = false;

            AppUserManager.Update(user);

            // Generate a new email confirmation token for this user.
            GenerateEmailConfirmationToken(user.Id);

            return(stggResult);
        }