Пример #1
0
        public async Task <NextPowerball> GetNextPowerball()
        {
            NextPowerball nextPowerball = null;
            HttpClient    client        = new HttpClient();

            client.BaseAddress = new Uri(_configuration.GetSection("BaseUrl").Value);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = await client.GetAsync("/api/powerball/GetNextPowerball");

            if (response.IsSuccessStatusCode)
            {
                nextPowerball = await response.Content.ReadAsAsync <NextPowerball>();

                return(nextPowerball);
            }

            return(null);
        }
Пример #2
0
        public async void build_next_powerball()
        {
            next_powerball = null;
            try
            {
                var response = client.GetAsync("/api/powerball/GetNextPowerball").Result;

                if (response.IsSuccessStatusCode)
                {
                    next_powerball = JsonConvert.DeserializeObject <NextPowerball>(await response.Content.ReadAsStringAsync());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }