示例#1
0
        private ManageAccountViewModel GetBaseManageAccountViewModel()
        {
            ManageAccountViewModel viewModel = new ManageAccountViewModel();
            string currentUserId = User.Identity.GetUserId();
            ApplicationUser user = userManager.FindById(currentUserId);
            viewModel.PasswordViewModel = HasPassword() ? (PasswordViewModel)new ChangePasswordViewModel() : new SetPasswordViewModel();
            ChangeEmailViewModel emailViewModel = new ChangeEmailViewModel();
            emailViewModel.EmailAddress = user.Email;
            viewModel.ChangeEmailViewModel = emailViewModel;

            var bggUser = _userRetriever.RetrieveUserInformation(user).BoardGameGeekUser;
            if (bggUser != null)
            {
                viewModel.BoardGameGeekIntegrationModel = new BoardGameGeekIntegrationModel
                {
                    BoardGameGeekUserName = bggUser.Name,
                    AvatarUrl = bggUser.Avatar,
                    IntegrationComplete = true,
                    BoardGameGeekUserUrl = BoardGameGeekUriBuilder.BuildBoardGameGeekUserUri(bggUser.Name)
                };
            }



            return viewModel;
        }
示例#2
0
 public virtual async Task<ActionResult> ChangeEmailAddress(ChangeEmailViewModel model)
 {
     var parentViewModel = GetBaseManageAccountViewModel();
     if (!ModelState.IsValid)
     {
         return RedirectToAction("Manage", new { Message = ManageMessageId.Error });
     }
     var result = await userManager.SetEmailAsync(User.Identity.GetUserId(), model.EmailAddress.Trim());
     if (result.Succeeded)
     {
         return RedirectToAction("Manage", new { Message = ManageMessageId.ChangeEmailSuccess });
     }
     AddErrors(result, "email");
     return RedirectToAction("Manage", new { Message = ManageMessageId.Error });
 }