public ActionResult Edit(int id, GroceryClient goc) { string data = JsonConvert.SerializeObject(goc); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PutAsync(client.BaseAddress + "/Grocery/" + id, content).Result; if (response.IsSuccessStatusCode) { return(Ok(goc)); } return(BadRequest()); }
//[Route("GetDetail")] public IActionResult GetDetails(int id) { GroceryClient obj = new GroceryClient(); HttpResponseMessage response = client.GetAsync(client.BaseAddress + "/Grocery/" + id).Result; if (response.IsSuccessStatusCode) { string data = response.Content.ReadAsStringAsync().Result; obj = JsonConvert.DeserializeObject <GroceryClient>(data); } return(Ok(obj)); }