예제 #1
0
        public ActionResult Edit(PODetailViewModel PODetailViewModel)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:19450/api/PODETAILs");

                //HTTP POST
                var putTask = client.PutAsJsonAsync <PODetailViewModel>("PODETAILs", PODetailViewModel);
                putTask.Wait();

                var result = putTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(PODetailViewModel));
        }
예제 #2
0
        public ActionResult Create(PODetailViewModel PODetailViewModel)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:19450/api/PODETAILs");

                //HTTP POST
                var postTask = client.PostAsJsonAsync <PODetailViewModel>("PODETAILs", PODetailViewModel);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }

            ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");

            return(View(PODetailViewModel));
        }
예제 #3
0
        public ActionResult Edit(string id)
        {
            PODetailViewModel PODetailViewModel = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:19450/api/");
                //HTTP GET
                var responseTask = client.GetAsync("PODETAILs?id=" + id);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <PODetailViewModel>();
                    readTask.Wait();

                    PODetailViewModel = readTask.Result;
                }
            }
            return(View(PODetailViewModel));
        }