示例#1
0
        public ActionResult Edit(int id, string description, Jdf jdf)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8080");

                //HTTP POST
                var putTask = client.PutAsJsonAsync <Jdf>("/mettreAjourDescriptionByJDFId/" + description + "/" + id, jdf);
                putTask.Wait();

                var result = putTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(jdf));
        }
示例#2
0
        public async Task <ActionResult> Create(Jdf jdf)
        {
            string Baseurl = "http://localhost:8080";

            using (var dm = new HttpClient())
            {
                dm.BaseAddress = new Uri(Baseurl);
                dm.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                // client.DefaultRequestHeaders.Add("X-Miva-API-Authorization", "MIVA xxxxxxxxxxxxxxxxxxxxxx");
                var response = await dm.PostAsJsonAsync("add-jdf", jdf);

                if (response.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(jdf));
        }
示例#3
0
        // GET: Kid/Edit/5
        public ActionResult Edit(int id)
        {
            Jdf jdf = null;

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

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

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