public IHttpActionResult Postjsondatatbl(jsondatatbl jsondatatbl) { db.jsondatatbls.Add(jsondatatbl); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = jsondatatbl.id }, jsondatatbl)); }
public IHttpActionResult Putjsondatatbl(int id, jsondatatbl jsondatatbl) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != jsondatatbl.id) { return(BadRequest()); } db.Entry(jsondatatbl).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!jsondatatblExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getjsondatatbl(int id) { jsondatatbl jsondatatbl = db.jsondatatbls.Find(id); if (jsondatatbl == null) { return(NotFound()); } return(Ok(jsondatatbl)); }
public IHttpActionResult Postjsondatatbl(jsondatatbl jsondatatbl) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.jsondatatbls.Add(jsondatatbl); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = jsondatatbl.id }, jsondatatbl)); }
public IHttpActionResult Deletejsondatatbl(int id) { jsondatatbl jsondatatbl = db.jsondatatbls.Find(id); if (jsondatatbl == null) { return(NotFound()); } db.jsondatatbls.Remove(jsondatatbl); db.SaveChanges(); return(Ok(jsondatatbl)); }
public ActionResult save(jsondata jdata) { if (ModelState.IsValid == true) { jsondatatbl tbl = new jsondatatbl(); tbl.name = jdata.name; tbl.gender = jdata.gender; if (jdata.hobbie.Count != 0) { for (int i = 0; i < jdata.hobbie.Count; i++) { if (i == 0) { tbl.hobbie1 = jdata.hobbie[0]; } if (i == 1) { tbl.hobbie2 = jdata.hobbie[1]; } if (i == 2) { tbl.hobbie3 = jdata.hobbie[2]; } } } else { tbl.hobbie1 = "NULL"; tbl.hobbie2 = "NULL"; tbl.hobbie3 = "NULL"; } HttpResponseMessage response = global.webclient.PostAsJsonAsync("jsondatatbls", tbl).Result; return(View(tbl)); } else { return(View("~/Views/Home/readJSON.cshtml")); } }