Esempio n. 1
0
        //Get match timeline by match ID
        public async Task <MatchTimelineDto> GetMatchTimelineAsync(long matchID)
        {
            MatchTimelineDto timeline = null;
            string           request  = "/lol/match/" + M_VERSION + "/timelines/by-match/" + matchID;
            string           response = await GET(request);

            timeline = JsonConvert.DeserializeObject <MatchTimelineDto>(response);
            return(timeline);
        }
        public static Match ConverMatchDtoToMatch(MatchDto matchDto, MatchTimelineDto matchTimelineDto)
        {
            if (matchDto == null || matchTimelineDto == null)
            {
                return(new Match());
            }

            try
            {
                return(new Match
                {
                    GameDuration = TimeSpanUtils.ConvertTimespanToFriendly(Convert.ToInt32(matchDto.GameDuration.TotalSeconds)),
                    GameDate = matchDto.GameDate,
                    GamePatch = matchDto.GamePatch,
                    WinningTeamId = matchDto.WinningTeamId,

                    TeamOne = ConvertMatchTeamDtoToMatchTeam
                              (
                        matchDto.Teams.ElementAtOrDefault(0),
                        matchTimelineDto.Events
                              ),

                    TeamTwo = ConvertMatchTeamDtoToMatchTeam
                              (
                        matchDto.Teams.ElementAtOrDefault(1),
                        matchTimelineDto.Events
                              )
                });
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught converting MatchDto to Match : " + e.Message);
            }

            return(new Match());
        }