Example #1
0
        public async Task <StandingsEntity> SearchStandings(string Code)
        {
            string url = string.Format("{0}competitions/{1}/standings", UrlBase, Code);

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("X-Auth-Token", Token);
                var resposta = await client.GetStringAsync(url);

                StandingsEntity retorno = JsonConvert.DeserializeObject <StandingsEntity>(resposta);
                return(retorno);
            }
        }
        public StandingsDataDTO MapToStandingsDataDTO(StandingsEntity source, StandingsDataDTO target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = new StandingsDataDTO();
            }

            target.CleanestDriver      = MapToMemberInfoDTO(source.CleanestDriver);
            target.MostPenaltiesDriver = MapToMemberInfoDTO(source.MostPenaltiesDriver);
            target.MostPolesDriver     = MapToMemberInfoDTO(source.MostPolesDriver);
            target.MostWinsDriver      = MapToMemberInfoDTO(source.MostWinsDriver);
            target.Scoring             = MapToScoringInfoDTO(source.Scoring);
            target.ScoringTableId      = source.ScoringTable.ScoringTableId;
            target.StandingsRows       = source.StandingsRows.Select(x => MapToStandingsRowDataDTO(x)).ToArray();

            return(target);
        }
        public StandingsDataDTO MapToStandingsDataDTO(StandingsEntity source, StandingsDataDTO target = null)
        {
            if (source == null)
            {
                return(null);
            }
            if (target == null)
            {
                target = new StandingsDataDTO();
            }

            target.CleanestDriverId      = source.CleanestDriver?.MemberId;                 // MapToMemberInfoDTO(source.CleanestDriver);
            target.MostPenaltiesDriverId = source.MostPenaltiesDriver?.MemberId;            // MapToMemberInfoDTO(source.MostPenaltiesDriver);
            target.MostPolesDriverId     = source.MostPolesDriver?.MemberId;                // MapToMemberInfoDTO(source.MostPolesDriver);
            target.MostWinsDriverId      = source.MostWinsDriver?.MemberId;                 // MapToMemberInfoDTO(source.MostWinsDriver);
            target.ScoringId             = (source.Scoring?.ScoringId).GetValueOrDefault(); // MapToScoringInfoDTO(source.Scoring);
            target.ScoringTableId        = source.ScoringTable.ScoringTableId;
            target.StandingsRows         = source.StandingsRows.Select(x => MapToStandingsRowDataDTO(x)).ToArray();
            target.SessionId             = source.SessionId;
            target.Name = source.ScoringTable.Name;

            return(target);
        }