Ejemplo n.º 1
0
        public async Task OnGet(int id)
        {
            var matchId = id; //TODO routing konusunu araştırınca burayı düzelt

            var matchStats = await _stat.GetStatsByMatchId(matchId);

            var match = matchStats.Select(p => p.Match).Distinct().First();

            MatchDetailInfo.MatchInfo = match;
            MatchDetailInfo.HomeTeam  = _team.GetTeamDetailByTeamResponse(_stat, match.HomeTeam, matchStats);
            MatchDetailInfo.AwayTeam  = _team.GetTeamDetailByTeamResponse(_stat, match.AwayTeam, matchStats);
        }
        public async Task OnGet(int id)
        {
            var playerId = id;

            var player = await _player.GetById(playerId);

            PlayerDetailInfo.Player = player;

            var playerStats = await _stat.GetStatsByPlayerId(playerId);

            playerStats = playerStats.OrderBy(p => p.Match.MatchDate).ThenBy(p => p.Match.Order).ThenBy(p => p.Team.Id).ToList();

            var totalStats = _stat.GetTotalStats(playerStats);

            var perMatchStats = _stat.GetPerMatchStats(totalStats, playerStats);

            PlayerDetailInfo.PenaltyRatio = _stat.GetPenaltyRatio(totalStats.PenaltyScore, totalStats.MissedPenalty);

            PlayerDetailInfo.TotalStats    = totalStats;
            PlayerDetailInfo.PerMatchStats = perMatchStats;

            var allMatchStats = await _stat.GetAll();

            PlayerDetailInfo.MatchForms  = _stat.GetMatchFormsByPlayerId(allMatchStats, playerId);
            PlayerDetailInfo.TotalWins   = _stat.GetTotalWinsByMatchForms(PlayerDetailInfo.MatchForms);
            PlayerDetailInfo.TotalLooses = _stat.GetTotalLoosesByMatchForms(PlayerDetailInfo.MatchForms);
            PlayerDetailInfo.WinRatio    = _stat.GetWinRatioByMatchForms(PlayerDetailInfo.MatchForms);
            PlayerDetailInfo.LooseRatio  = _stat.GetLooseRatioByMatchForms(PlayerDetailInfo.MatchForms);

            foreach (var stat in playerStats)
            {
                var playerStatDetail = new PlayerStatDetail
                {
                    PlayerStat = stat,
                    MatchStats = await _stat.GetStatsByMatchId(stat.MatchId)
                };

                playerStatDetail.HomeTeamScore = _stat.GetScoreByStatsAndTeamId(playerStatDetail.MatchStats, stat.Match.HomeTeamId, stat.Match.AwayTeamId);
                playerStatDetail.AwayTeamScore = _stat.GetScoreByStatsAndTeamId(playerStatDetail.MatchStats, stat.Match.AwayTeamId, stat.Match.HomeTeamId);

                PlayerDetailInfo.PlayerStats.Add(playerStatDetail);
            }
        }
Ejemplo n.º 3
0
        public async Task OnGet()
        {
            var matches = await _match.GetAll();

            foreach (var match in matches)
            {
                var matchDetail = new MatchDetail();
                var matchStats  = await _stat.GetStatsByMatchId(match.Id);

                matchDetail.MatchInfo = matchStats.Select(p => p.Match).Distinct().FirstOrDefault();

                matchDetail.HomeTeamScore = _stat.GetScoreByStatsAndTeamId(matchStats, matchDetail.MatchInfo.HomeTeamId, matchDetail.MatchInfo.AwayTeamId);
                matchDetail.AwayTeamScore = _stat.GetScoreByStatsAndTeamId(matchStats, matchDetail.MatchInfo.AwayTeamId, matchDetail.MatchInfo.HomeTeamId);

                Matches.Add(matchDetail);
            }
            var sortedMatches = Matches.OrderBy(p => p.MatchInfo.MatchDate).ThenBy(p => p.MatchInfo.Order).ToList();

            Matches = sortedMatches;
        }