Exemple #1
0
        /// <summary>
        /// Gets constructor info.
        /// </summary>
        /// <param name="constructor">Constructor ID.</param>
        /// <returns>Constructor info.</returns>
        public async Task <Constructor> GetConstructorAsync(string constructor)
        {
            string uri = _api.Constructor(constructor);

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

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

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