Beispiel #1
0
        /// <summary>
        /// Gets drivers info. It can be filtered by year and round.
        /// </summary>
        /// <param name="year">Drivers of this year.</param>
        /// <param name="round">Drivers of this round that year.</param>
        /// <returns></returns>
        public async Task <DriverTable> GetDriversAsync(int?year = null, int?round = null)
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.Drivers(year, round));

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

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

            return(null);
        }