/// <summary> /// Method gets all customers data from the DB. It's defined as asynchronous /// to return the view for the index and customer list values. /// </summary> /// <returns></returns> public async Task <IActionResult> Index() { List <CustomerDTO> dto = new List <CustomerDTO>(); HttpClient client = _customerAPI.InitializeClient(); HttpResponseMessage res = await client.GetAsync("api/customers/Get"); //Checking the response is successful or not which is sent using HttpClient if (res.IsSuccessStatusCode) { //Storing the response details recieved from web api var result = res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the Employee list dto = JsonConvert.DeserializeObject <List <CustomerDTO> >(result); } //returning the employee list to view return(View(dto)); }