public async Task <IActionResult> Edit(int Id) { ValeData Vale = new ValeData(); HttpClient client = _api.ListVale(); HttpResponseMessage res = await client.GetAsync($"Vale/{Id}"); if (res.IsSuccessStatusCode) { var resutlado = res.Content.ReadAsStringAsync().Result; Vale = JsonConvert.DeserializeObject <ValeData>(resutlado); } return(View(Vale)); }
public ActionResult Create(ValeData vale) { HttpClient client = _api.ListVale(); //http post var jsonContent = JsonConvert.SerializeObject(vale); var contentString = new StringContent(jsonContent, Encoding.UTF8, "application/json"); contentString.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var postBack = client.PostAsync("Vale", contentString); var resultado = postBack.Result; if (resultado.IsSuccessStatusCode) { return(RedirectToAction("index")); } return(View()); }