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(".", ",")); }
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); }