Пример #1
0
        /// <summary>
        /// Gets race results given the year and round of the race.
        /// </summary>
        /// <param name="year">Year of the race.</param>
        /// <param name="round">Round of the season.</param>
        /// <returns>Race results info.</returns>
        public async Task <RaceTable> GetRaceResultsAsync(int year, int round)
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.RaceResults(year, round));

                if (response.IsSuccessStatusCode)
                {
                    string content = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <DataErgastRaces>(DataErgast.RemoveMRData(content))?.RaceTable);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\tERROR {0}", ex.Message);
            }

            return(null);
        }