Пример #1
0
        public async void build_next_megamillions()
        {
            try
            {
                var response = client.GetAsync("/api/megamillion/GetNextMegamillion").Result;

                if (response.IsSuccessStatusCode)
                {
                    next_megamillion =
                        JsonConvert.DeserializeObject <NextMegamillion>(await response.Content.ReadAsStringAsync());
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }
        }
        public async Task <NextMegamillion> GetNextMegamillion()
        {
            NextMegamillion nextMegamillion = null;
            HttpClient      client          = new HttpClient();

            client.BaseAddress = new Uri(this.configuration.GetSection("BaseUrl").Value);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = await client.GetAsync("/api/megamillion/GetNextMegamillion");

            if (response.IsSuccessStatusCode)
            {
                nextMegamillion = await response.Content.ReadAsAsync <NextMegamillion>();

                return(nextMegamillion);
            }

            return(null);
        }