public IActionResult Delete(int id) { using (var data = new ServicoData()) data.Delete(id); return(RedirectToAction("Index")); }
public IActionResult Create(Servico servico) { if (!ModelState.IsValid) { return(View(servico)); } using (var data = new ServicoData()) data.Create(servico); return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(int Id) { ServicoData Servico = new ServicoData(); HttpClient client = _api.ListServico(); HttpResponseMessage res = await client.GetAsync($"Servico/{Id}"); if (res.IsSuccessStatusCode) { var resutlado = res.Content.ReadAsStringAsync().Result; Servico = JsonConvert.DeserializeObject <ServicoData>(resutlado); } return(View(Servico)); }
public ActionResult Edit(ServicoData servico) { HttpClient client = _api.ListServico(); //http post var jsonContent = JsonConvert.SerializeObject(servico); var contentString = new StringContent(jsonContent, Encoding.UTF8, "application/json"); contentString.Headers.ContentType = new MediaTypeHeaderValue("application/json"); // contentString.Headers.Add("Session-Token", session_token); var postBack = client.PutAsync($"Servico/{servico.ServicoId}", contentString); var resultado = postBack.Result; if (resultado.IsSuccessStatusCode) { return(RedirectToAction("index")); } return(View()); }
public IActionResult Update(int id) { using (var data = new ServicoData()) return(View(data.Read(id))); }
public IActionResult Index() { using (var data = new ServicoData()) return(View(data.Read())); }