예제 #1
0
        public async Task <ActionResult> Delete(SBclient p)
        {
            int bid = Convert.ToInt32(TempData["CustomerId"]);

            using (var httpClient = new HttpClient())
            {
                using (var response = await httpClient.DeleteAsync("http://localhost:46019/api/SBaccount/" + bid))

                {
                    string apiResponse = await response.Content.ReadAsStringAsync();
                }
            }
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public async Task <ActionResult> Create(SBclient p)
        {
            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(p), Encoding.UTF8, "application/json");

                using (var response = await httpClient.PostAsync("http://localhost:46019/api/SBaccount/", content))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    var obj = JsonConvert.DeserializeObject <SBclient>(apiResponse);
                }
            }
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public async Task <ActionResult> Delete(int id)
        {
            TempData["CustomerId"] = id;
            SBclient p = new SBclient();

            using (var httpClient = new HttpClient())
            {
                using (var response = await httpClient.GetAsync("http://localhost:46019/api/SBaccount/" + id))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    p = JsonConvert.DeserializeObject <SBclient>(apiResponse);
                }
            }
            return(View(p));
        }
예제 #4
0
        public async Task <ActionResult> Edit(SBclient b)
        {
            int bid = Convert.ToInt32(TempData["CustomerId"]);

            using (var httpClient = new HttpClient())
            {
                StringContent content1 = new StringContent(JsonConvert.SerializeObject(b), Encoding.UTF8, "application/json");
                using (var response = await httpClient.PutAsync("http://localhost:46019/api/SBaccount/" + bid, content1))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    b = JsonConvert.DeserializeObject <SBclient>(apiResponse);
                }
            }
            return(RedirectToAction("Index"));
        }