Esempio n. 1
0
        /// <summary>
        /// Gets all laps set in the whole race, starting in the offset.
        /// </summary>
        /// <param name="year">Year of the race.</param>
        /// <param name="round">Round of the season.</param>
        /// <param name="offset">Offset to start in.</param>
        /// <returns>Laps info.</returns>
        private async Task <Race> GetLapsByRace(int year, int round, int offset)
        {
            string uri = _api.LapsByRace(year, round, offset);

            try
            {
                HttpResponseMessage response = await _client.GetAsync(uri);

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