Ejemplo n.º 1
0
        /// <summary>
        /// Gets all pit stops 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 pit stops info.</returns>
        public async Task <Race> PitStopsByRaceAndDriverAsync(int year, int round, string driver)
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.PitStopsByRaceAndDriver(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);
        }