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); }
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); }
public virtual HttpResponseMessage GetUserInformation(string userId) { var userInformation = userRetriever.RetrieveUserInformation(CurrentUser); var userInformationMessage = this.transformer.Transform <UserInformationMessage>(userInformation); return(Request.CreateResponse(HttpStatusCode.OK, userInformationMessage)); }
public int?ImportBoardGameGeekGames(ApplicationUser applicationUser) { if (applicationUser == null) { throw new ArgumentNullException(); } var bggUser = _userRetriever.RetrieveUserInformation(applicationUser)?.BoardGameGeekUser; if (bggUser != null) { var userGames = _boardGameGeekApiClient.GetUserGames(bggUser.Name); if (!userGames.Any()) { return(null); } var currentGames = GetCurrentGames(applicationUser); var pendingGames = GetPendingGames(userGames, currentGames); if (!pendingGames.Any()) { return(0); } var longRunningClients = GlobalHost.ConnectionManager.GetHubContext <LongRunningTaskHub>().Clients.Group(applicationUser.CurrentGamingGroupId.ToString()); int gamesImported = 0; var gameNamesImported = new List <string>(); CreateGameDefinitions(applicationUser, pendingGames, gamesImported, longRunningClients, gameNamesImported); return(pendingGames.Count); } return(null); }
public virtual ActionResult CreatePartial(ApplicationUser currentUser) { var bggUser = _userRetriever.RetrieveUserInformation(currentUser).BoardGameGeekUser; return(View(MVC.GameDefinition.Views._CreatePartial, new CreateGameDefinitionViewModel() { BGGUserName = bggUser?.Name, GamingGroupId = currentUser.CurrentGamingGroupId.Value })); }
public int?ImportBoardGameGeekGames(ApplicationUser applicationUser) { if (applicationUser == null) { throw new ArgumentNullException(); } var bggUser = _userRetriever.RetrieveUserInformation(applicationUser)?.BoardGameGeekUser; if (bggUser != null) { var userGames = _boardGameGeekApiClient.GetUserGames(bggUser.Name); if (!userGames.Any()) { return(null); } else { var currentGames = GetCurrentGames(applicationUser); var pendingGames = GetPendingGames(userGames, currentGames); if (!pendingGames.Any()) { return(0); } else { var longRunningClients = GlobalHost.ConnectionManager.GetHubContext <LongRunningTaskHub>().Clients.Group(applicationUser.CurrentGamingGroupId.ToString()); int gamesImported = 0; var gameNamesImported = new List <string>(); foreach (var bggGame in pendingGames) { var gameName = $"{bggGame.Name} ({bggGame.YearPublished})"; gamesImported++; longRunningClients.BGGImportDetailsProgress(gamesImported, pendingGames.Count, gameName); if (!gameNamesImported.Contains(gameName)) { _gameDefinitionSaver.CreateGameDefinition(new CreateGameDefinitionRequest() { Name = $"{bggGame.Name} ({bggGame.YearPublished})", BoardGameGeekGameDefinitionId = bggGame.GameId, Active = true }, applicationUser); } gameNamesImported.Add(gameName); } return(pendingGames.Count); } } } return(null); }
public virtual HttpResponseMessage GetUserInformation(string userId) { var userInformation = _userRetriever.RetrieveUserInformation(CurrentUser); var userInformationMessage = _transformer.Transform <UserInformationMessage>(userInformation); userInformationMessage.GamingGroups.ForEach(x => x.NemeStatsUrl = AbsoluteUrlBuilder.GetGamingGroupDetailsUrl(x.GamingGroupId)); userInformationMessage.Players.ForEach(x => x.NemeStatsUrl = AbsoluteUrlBuilder.GetPlayerDetailsUrl(x.PlayerId)); return(Request.CreateResponse(HttpStatusCode.OK, userInformationMessage)); }