public async Task <ActionResult> ListProduct() { List <Product> products = new List <Product>(); HttpClient product = _api.Initial(); HttpResponseMessage res = await product.GetAsync("http://kallsonysservices.cian.net.co/rest/productos/getproductos"); if (res.IsSuccessStatusCode) { var results = res.Content.ReadAsStringAsync().Result; products = JsonConvert.DeserializeObject <List <Product> >(results); } return(View(products)); }
// GET: /<controller>/ public async Task <IActionResult> ProductList() { List <Product> product = new List <Product>(); HttpClient client = _productapi.Initial(); HttpResponseMessage res = await client.GetAsync("/api/product"); if (res.IsSuccessStatusCode) { var result = res.Content.ReadAsStringAsync().Result; product = JsonConvert.DeserializeObject <List <Product> >(result); } return(View(product)); }
public async Task <IActionResult> Details(int id) { try { _log4net.Info("ProductController Getting Product By ID Successfull"); var product = new Product(); HttpClient client = _api.Initial(); HttpResponseMessage res = await client.GetAsync($"api/Product/{id}"); if (res.IsSuccessStatusCode) { var results = res.Content.ReadAsStringAsync().Result; product = JsonConvert.DeserializeObject <Product>(results); } return(View(product)); } catch (Exception ex) { _log4net.Info("ProductController Getting Product By ID Failed"); return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Index() { List <ProductData> products = new List <ProductData>(); HttpClient client = _api.Initial(); HttpResponseMessage res = await client.GetAsync("products"); if (res.IsSuccessStatusCode) { var results = res.Content.ReadAsStringAsync().Result; products = JsonConvert.DeserializeObject <List <ProductData> >(results); } return(View(products)); }