Ejemplo n.º 1
0
        /// <summary>
        /// Gets all races a constructors has set a fastest lap.
        /// </summary>
        /// <param name="constructor">Constructor ID.</param>
        /// <returns>Races info.</returns>
        public async Task <RaceTable> FastestLapsByConstructorAsync(string constructor)
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.FastestLapsByConstructor(constructor));

                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);
        }