public string delete(API_profile pro) { Application1Entities api = new Application1Entities(); API_profile obj = api.API_profile.Single(x => x.id == pro.id); api.API_profile.Remove(obj); api.SaveChanges(); return("Success"); }
public string update(API_profile pro) { Application1Entities api = new Application1Entities(); API_profile obj = api.API_profile.Single(x => x.id == pro.id); obj.name = pro.name; obj.address = pro.address; api.SaveChanges(); return("Success"); }
public string add(API_profile pro) { Application1Entities api = new Application1Entities(); API_profile obj = new API_profile(); obj.id = pro.id; obj.name = pro.name; obj.address = pro.address; api.API_profile.Add(obj); api.SaveChanges(); return("Success"); }
public ActionResult Edit(API_profile pro) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:57591/"); //HTTP POST var putTask = client.PostAsJsonAsync("update", pro); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View(pro)); }
public ActionResult Delete(API_profile pro) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:57591/"); //HTTP DELETE var deleteTask = client.PostAsJsonAsync("delete", pro); deleteTask.Wait(); var result = deleteTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { API_profile obj = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:57591/"); //HTTP GET var responseTask = client.GetAsync("search?sid=" + id.ToString()); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <API_profile>(); readTask.Wait(); obj = readTask.Result; } } return(View(obj)); }