Exemplo n.º 1
0
        private void ParseCotizacion(HttpResponseMessage response, Cotizacion coti)
        {
            var result = response.Content.ReadAsAsync <List <String> >().Result;

            coti.Venta  = Convert.ToDouble(result[0].Replace(".", ","));
            coti.Compra = Convert.ToDouble(result[1].Replace(".", ","));
        }
Exemplo n.º 2
0
        public Cotizacion GetCotizacion()
        {
            var coti = new Cotizacion();

            var client = new HttpClient();

            client.BaseAddress = new Uri("http://www.bancoprovincia.com.ar/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));



            HttpResponseMessage response = client.GetAsync("Principal/Dolar").Result;

            if (response.IsSuccessStatusCode)
            {
                ParseCotizacion(response, coti);
            }

            return(coti);
        }