private void PopulatePlayerGameResults(PlayerDetails playerDetails, PlayerDetailsViewModel playerDetailsViewModel) { playerDetailsViewModel.PlayerGameResultDetails = new List <GameResultViewModel>(); GameResultViewModel gameResultViewModel; foreach (PlayerGameResult playerGameResult in playerDetails.PlayerGameResults) { gameResultViewModel = gameResultViewModelBuilder.Build(playerGameResult); playerDetailsViewModel.PlayerGameResultDetails.Add(gameResultViewModel); } }
public PlayedGameDetailsViewModel Build(PlayedGame playedGame, ApplicationUser currentUser, bool showPointsScored = false) { ValidateArguments(playedGame); PlayedGameDetailsViewModel summary = new PlayedGameDetailsViewModel(); summary.GameDefinitionName = playedGame.GameDefinition.Name; summary.GameDefinitionId = playedGame.GameDefinitionId; summary.PlayedGameId = playedGame.Id; summary.DatePlayed = playedGame.DatePlayed; summary.GamingGroupId = playedGame.GamingGroup.Id; summary.GamingGroupName = playedGame.GamingGroup.Name; summary.WinnerType = playedGame.WinnerType; if (playedGame.GameDefinition.BoardGameGeekGameDefinition != null) { summary.ThumbnailImageUrl = playedGame.GameDefinition.BoardGameGeekGameDefinition.Thumbnail; summary.ImageUrl = playedGame.GameDefinition.BoardGameGeekGameDefinition.Image; } summary.BoardGameGeekUri = BoardGameGeekUriBuilder.BuildBoardGameGeekGameUri(playedGame.GameDefinition.BoardGameGeekGameDefinitionId); if (playedGame.Notes != null) { summary.Notes = playedGame.Notes.Replace(Environment.NewLine, NEWLINE_REPLACEMENT_FOR_HTML); } summary.UserCanEdit = (currentUser != null && playedGame.GamingGroupId == currentUser.CurrentGamingGroupId); summary.PlayerResults = new List <GameResultViewModel>(); showPointsScored = showPointsScored && playedGame.PlayerGameResults.All(pgr => pgr.PointsScored.HasValue && pgr.PointsScored > 0); foreach (PlayerGameResult playerGameResult in playedGame.PlayerGameResults) { summary.PlayerResults.Add(playerResultBuilder.Build(playerGameResult, showPointsScored)); } return(summary); }
public PlayedGameDetailsViewModel Build(PlayedGame playedGame, ApplicationUser currentUser) { ValidateArguments(playedGame); PlayedGameDetailsViewModel summary = new PlayedGameDetailsViewModel(); summary.GameDefinitionName = playedGame.GameDefinition.Name; summary.GameDefinitionId = playedGame.GameDefinitionId; summary.PlayedGameId = playedGame.Id; summary.DatePlayed = playedGame.DatePlayed; summary.GamingGroupId = playedGame.GamingGroup.Id; summary.GamingGroupName = playedGame.GamingGroup.Name; if (playedGame.GameDefinition.BoardGameGeekGameDefinition != null) { summary.ThumbnailImageUrl = playedGame.GameDefinition.BoardGameGeekGameDefinition.Thumbnail; } summary.BoardGameGeekUri = BoardGameGeekUriBuilder.BuildBoardGameGeekGameUri(playedGame.GameDefinition.BoardGameGeekGameDefinitionId); if (playedGame.Notes != null) { summary.Notes = playedGame.Notes.Replace(Environment.NewLine, NEWLINE_REPLACEMENT_FOR_HTML); } summary.UserCanEdit = (currentUser != null && playedGame.GamingGroupId == currentUser.CurrentGamingGroupId); summary.PlayerResults = new List <GameResultViewModel>(); foreach (PlayerGameResult playerGameResult in playedGame.PlayerGameResults) { summary.PlayerResults.Add(playerResultBuilder.Build(playerGameResult)); } var gameRanks = playedGame.PlayerGameResults.Select(x => x.GameRank).ToList(); summary.WinnerType = CalculateWinnerType(gameRanks); return(summary); }