public ActionResult Create(Contract_rent cr) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:8081/"); //HTTP GET var responseTask = client.PostAsJsonAsync <Contract_rent>("/Contract_Rent/Add", cr).Result; } return(RedirectToAction("Index")); }
public ActionResult Edit(Contract_rent contract_Rent) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:8081/Contract_Rent/"); //HTTP POST var putTask = client.PutAsJsonAsync <Contract_rent>("put", contract_Rent); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View(contract_Rent)); }
// GET: ContractRent/Details/5 public ActionResult Details(int id_user, int id_property) { Contract_rent contract_Rent = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:8081/Contract_Rent/"); //HTTP GET var responseTask = client.GetAsync("getOne/" + id_user + "/" + id_property); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <Contract_rent>(); readTask.Wait(); contract_Rent = readTask.Result; } } return(View(contract_Rent)); }