public async Task <ActionResult> Delete(WForecast b) { string wid = TempData["City"].ToString(); using (var httpClient = new HttpClient()) { using (var response = await httpClient.DeleteAsync("http://localhost:14700/api/Weathers/" + wid)) { string apiResponse = await response.Content.ReadAsStringAsync(); } } return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(WForecast w) { using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(w), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync("http://localhost:14700/api/Weathers/", content)) { string apiResponse = await response.Content.ReadAsStringAsync(); var obj = JsonConvert.DeserializeObject <WForecast>(apiResponse); } } return(RedirectToAction("Index")); }
public async Task <ActionResult> Delete(string city) { TempData["City"] = city; WForecast w = new WForecast(); using (var httpClient = new HttpClient()) { using (var response = await httpClient.GetAsync("http://localhost:14700/api/Weathers/" + city)) { string apiResponse = await response.Content.ReadAsStringAsync(); w = JsonConvert.DeserializeObject <WForecast>(apiResponse); } } return(View(w)); }
public async Task <ActionResult> Edit(WForecast w) { string wid = TempData["CityId"].ToString(); using (var httpClient = new HttpClient()) { StringContent content1 = new StringContent(JsonConvert.SerializeObject(w), Encoding.UTF8, "application/json"); using (var response = await httpClient.PutAsync("http://localhost:14700/api/Weathers/" + wid, content1)) { string apiResponse = await response.Content.ReadAsStringAsync(); w = JsonConvert.DeserializeObject <WForecast>(apiResponse); } } return(RedirectToAction("Index")); }