public ActionResult CarData() { var carData = new CarDataViewModel(); const string apiUrl = "https://mobiledev.sunovacu.ca/api/Test/GetCars"; using (HttpClient client = new HttpClient()) { HttpResponseMessage response = client.GetAsync(apiUrl).Result; if (response.IsSuccessStatusCode) { var data = response.Content.ReadAsStringAsync().Result; var parsedCarData = JsonConvert.DeserializeObject <List <CarData> >(data); carData.CarDatas = parsedCarData; } else { // Add an error message here.. } } return(PartialView("CarDataPartial", carData)); }
public ActionResult Index() { var carData = new CarDataViewModel(); return(View(carData)); }