public ContentResult AjaxList() { org_Company Company = new org_Company(); org_Department Department = new org_Department(); string contentCom = "["; string contentDep = ""; for (int i = 0; i < db.org_Companies.ToList().LongCount(); i++) { contentCom += "{\"id\":\"" + db.org_Companies.ToList()[i].Company_ID + "\",\"text\":\"" + db.org_Companies.ToList()[i].Company_Name + "\",\"children\":["; for (int j = 0; j < db.org_Departments.ToList().LongCount(); j++) { if (db.org_Companies.ToList()[i].Company_ID == db.org_Departments.ToList()[j].Company_ID) { contentDep += "{\"id\":" + db.org_Departments.ToList()[j].Department_ID + ",\"text\":\"" + db.org_Departments.ToList()[j].Department_Name + "\"}"; } if (j != (db.org_Departments.ToList().LongCount() - 1)) { contentDep += ","; } } contentCom += contentDep + "]}"; contentDep = ""; if (i != (db.org_Companies.ToList().LongCount() - 1)) { contentCom += ","; } } contentCom += "]"; return(Content(contentCom)); }
public ActionResult DeleteConfirmed(int id) { org_Department org_department = db.org_Departments.Find(id); db.org_Departments.Remove(org_department); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /org_Department/Delete/5 public ActionResult Delete(int id = 0) { org_Department org_department = db.org_Departments.Find(id); if (org_department == null) { return(HttpNotFound()); } return(View(org_department)); }
public ActionResult Edit(org_Department org_department) { if (ModelState.IsValid) { db.Entry(org_department).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(org_department)); }
public ActionResult Create(org_Department org_department) { if (ModelState.IsValid) { db.org_Departments.Add(org_department); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(org_department)); }