Example #1
0
        /// <summary>
        /// Gets all laps set by a driver in a race.
        /// </summary>
        /// <param name="year">Year of the race.</param>
        /// <param name="round">Round of the season.</param>
        /// <param name="driver">Driver ID.</param>
        /// <returns>All laps info.</returns>
        public async Task <Race> LapsByRaceAndDriverAsync(int year, int round, string driver)
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.LapsByRaceAndDriver(year, round, driver));

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

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