Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            org_Company org_company = db.org_Companies.Find(id);

            db.org_Companies.Remove(org_company);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public override ActionResult ViewDetail(int autoKey, string errorMsg)
        {
            CompanyViewDetailModel pageModel = new CompanyViewDetailModel();
            org_Company            company   = db.org_Companies.Find(autoKey);

            pageModel.CompanyDetail = company.ToCompanyItem();
            pageModel.Parameters.Add(new NameValueItem("Company_ID", autoKey));
            return(View(pageModel));
        }
Exemplo n.º 4
0
        public ActionResult Delete(int id = 0)
        {
            org_Company org_company = db.org_Companies.Find(id);

            if (org_company == null)
            {
                return(HttpNotFound());
            }
            return(View(org_company));
        }
Exemplo n.º 5
0
        public ActionResult Create(org_Company org_company)
        {
            if (ModelState.IsValid)
            {
                db.org_Companies.Add(org_company);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(org_company));
        }
Exemplo n.º 6
0
        public static org_Company ToUpdateCompany(this CompanyItem CompanyItem)
        {
            org_Company Company = CompanyItem.ToCompany();

            return(Company);
        }
Exemplo n.º 7
0
 public static CompanyItem ToCompanyItem(this org_Company Company)
 {
     return(new CompanyItem(Company));
 }