internal virtual ManageAccountViewModel GetBaseManageAccountViewModel() { var viewModel = new ManageAccountViewModel(); var currentUserId = User.Identity.GetUserId(); var user = _userManager.FindById(currentUserId); viewModel.PasswordViewModel = HasPassword() ? (PasswordViewModel) new ChangePasswordViewModel() : new SetPasswordViewModel(); var emailViewModel = new ChangeEmailViewModel(); emailViewModel.EmailAddress = user.Email; viewModel.ChangeEmailViewModel = emailViewModel; var userInformation = _userRetriever.RetrieveUserInformation(user); var bggUser = userInformation.BoardGameGeekUser; if (bggUser != null) { viewModel.BoardGameGeekIntegrationModel = new BoardGameGeekIntegrationModel { BoardGameGeekUserName = bggUser.Name, AvatarUrl = bggUser.Avatar, IntegrationComplete = true, BoardGameGeekUserUrl = BoardGameGeekUriBuilder.BuildBoardGameGeekUserUri(bggUser.Name) }; } viewModel.GamingGroupsSummary = new GamingGroupsSummaryViewModel { ShowForEdit = true, GamingGroups = userInformation.GamingGroups.Select(x => _transformer.Transform <GamingGroupSummaryViewModel>(x)).ToList() }; return(viewModel); }
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); }