Esempio n. 1
0
        public async Task <MatchStats> GetMatchStatsAsync(string matchId)
        {
            MatchStats matchStats = await apiService.FetchMatchStatsAsync(matchId);

            MatchInfo matchInfo = null;

            try
            {
                matchInfo = await GetMatchInfoAsync(matchId);
            }
            catch { }
            if (matchInfo != null)
            {
                matchStats.CompetitionName = matchInfo.CompetitionName;
                matchStats.Teams[0].Players.ForEach(p =>
                {
                    p.PlayerInfo = matchInfo.TeamA.Players
                                   .FirstOrDefault((po) => po.Id == p.Id);
                });
                matchStats.Teams[1].Players.ForEach(p =>
                {
                    p.PlayerInfo = matchInfo.TeamB.Players
                                   .FirstOrDefault((po) => po.Id == p.Id);
                });
            }
            else
            {
                matchStats.Teams[0].Players.ForEach(p =>
                {
                    p.PlayerInfo = new PlayerInfo();
                });
                matchStats.Teams[1].Players.ForEach(p =>
                {
                    p.PlayerInfo = new PlayerInfo();
                });
            }
            matchStats.Teams.ForEach((t) =>
            {
                t.Players.Sort((p1, p2) => p2.PlayerStats.Kills.CompareTo(p1.PlayerStats.Kills));
            });
            return(matchStats);
        }