Exemplo n.º 1
0
        /// <summary>
        /// Gets all races a circuit has held.
        /// </summary>
        /// <param name="circuit">Circuit ID.</param>
        /// <returns>Races info.</returns>
        public async Task <RaceTable> RacesByCircuit(string circuit)
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.RacesByCircuit(circuit));

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