Esempio n. 1
0
 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"));
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        // 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));
        }