public IHttpActionResult PutPodetail(string id, Podetail podetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != podetail.pono) { return(BadRequest()); } db.Entry(podetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PodetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostPodetail(Podetail podetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Podetails.Add(podetail); try { db.SaveChanges(); } catch (DbUpdateException) { if (PodetailExists(podetail.pono)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = podetail.pono }, podetail)); }
public ActionResult Create(Podetail podetail) { try { using (client) { Task <HttpResponseMessage> responseTask = client.PostAsJsonAsync(url, podetail); responseTask.Wait(); //To store result of web api response. HttpResponseMessage result = responseTask.Result; //If success received if (result.IsSuccessStatusCode) { Task <Podetail> readTask = result.Content.ReadAsAsync <Podetail>(); readTask.Wait(); podetail = readTask.Result; } }; return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(string pono, string itcode, Podetail podetail) { try { using (client) { Task <HttpResponseMessage> responseTask = client.DeleteAsync(url + "?pono=" + pono + "&itcode=" + itcode); responseTask.Wait(); //To store result of web api response. HttpResponseMessage result = responseTask.Result; //If success received if (result.IsSuccessStatusCode) { Task <Podetail> readTask = result.Content.ReadAsAsync <Podetail>(); readTask.Wait(); podetail = readTask.Result; } }; return(RedirectToAction("Index")); } catch { return(View()); } }
public IHttpActionResult GetPodetail(string id) { Podetail podetail = db.Podetails.Find(id); if (podetail == null) { return(NotFound()); } return(Ok(podetail)); }
public IHttpActionResult DeletePodetail(string id) { Podetail podetail = db.Podetails.Find(id); if (podetail == null) { return(NotFound()); } db.Podetails.Remove(podetail); db.SaveChanges(); return(Ok(podetail)); }
// GET: Podetails/Details/5 public ActionResult Details(string pono, string itcode) { Podetail podetail = new Podetail(); using (client) { Task <HttpResponseMessage> responseTask = client.GetAsync(url + "?pono=" + pono + "&itcode=" + itcode); responseTask.Wait(); //To store result of web api response. HttpResponseMessage result = responseTask.Result; //If success received if (result.IsSuccessStatusCode) { Task <Podetail> readTask = result.Content.ReadAsAsync <Podetail>(); readTask.Wait(); podetail = readTask.Result; } }; return(View(podetail)); }