Esempio n. 1
0
        public async Task<ActionResult> EditAccount(EditAccountViewModel editModel)
        {

            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();

                ApplicationUser model = UserManager.FindById(userId);

                if (model != null)
                {
                    model.Nickname = editModel.Nickname;
                    model.DateOfBirth = editModel.DateOfBirth;
                    model.Email = editModel.Email;
                    model.UserName = editModel.Email;

                    IdentityResult result = await UserManager.UpdateAsync(model);

                }

                return RedirectToAction("Index");
            }

            return View(editModel);
        }
Esempio n. 2
0
        //
        // GET: /Manage/EditAccount
        public async Task<ActionResult> EditAccount(ManageMessageId? message)
        {
            ViewBag.Title = Resources.Resources.ManageController_EditAccount_Manage;

            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? Resources.Resources.ManageController_Index_password_changed
                : message == ManageMessageId.SetPasswordSuccess ? Resources.Resources.ManageController_Index_password_set
                : message == ManageMessageId.SetTwoFactorSuccess ? Resources.Resources.ManageController_Index_two_factor_authentication_provider_set
                : message == ManageMessageId.Error ? Resources.Resources.ManageController_Index_error
                : message == ManageMessageId.AddPhoneSuccess ? Resources.Resources.ManageController_Index_phone_number_added
                : message == ManageMessageId.RemovePhoneSuccess ? Resources.Resources.ManageController_phone_number_removed
                : "";

            var userId = User.Identity.GetUserId();
            var currentUser = UserManager.FindById(userId);

            // CG - Get all of the teams for the user's community and pass them via ViewBag through to the model.
            //var selectTeams = teamsService.GetTeamsByCommunity(user.Team.community);
            //ViewBag.teamList = new SelectList(selectTeams, "Id", "name");

            var model = new EditAccountViewModel
            {
                HasPassword = HasPassword(),
                PhoneNumber = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId),
                Nickname = currentUser.Nickname,
                Id = currentUser.Id,
                Email = currentUser.Email,
                DateOfBirth = currentUser.DateOfBirth
            };

            return View(model);
        }