public JsonResult Save(BaseQueryGraph model, FormCollection form) { if (model.id != 0) { if (ModelState.IsValid) { db.Entry(model).State = EntityState.Modified; if (form["querys"] != null) { model.query = form["querys"]; } db.SaveChanges(); } } else { if (form["querys"] != null) { model.query = form["querys"]; } db.BaseQueryGraphs.Add(model); db.SaveChanges(); } return(Json(model.id)); }
public ActionResult Form(int id = 0) { if (id == 0) { return(PartialView(new BaseQueryGraph())); } else { BaseQueryGraph model = db.BaseQueryGraphs.Find(id); return(PartialView(model)); } }
public JsonResult Delete(int id = 0) { BaseQueryGraph model = db.BaseQueryGraphs.Find(id); if (model != null) { var graph = db.BaseGraphs.FirstOrDefault(x => x.queryGraphID == model.id); if (graph != null) { Helper.executeNonQUery("delete from GraphsTypes where GraphID = " + graph.id, db); Helper.executeNonQUery("delete from Graphs where queryGraphID =" + model.id, db); } Helper.executeNonQUery("delete from BaseQueryGraph where id =" + model.id, db); //db.QueryGraphs.Remove(model); //db.SaveChanges(); } return(Json("ok", JsonRequestBehavior.AllowGet)); }