Пример #1
0
        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));
        }
Пример #2
0
        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"));
        }
Пример #3
0
        //
        // 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));
        }
Пример #4
0
 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));
 }
Пример #5
0
        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));
        }