public ActionResult CreateCompany(int? id)
 {
     if (id == null)
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     int _id = (int)id;
     CompanyEntity company = new CompanyEntity();
     company.ParentId = _id;
     return View(company);
 }
        public CompanyNode(CompanyNode parent, CompanyEntity company, TreeViewModel db)
        {
            this.parent = parent;
            this.company = company;
            if (this.company.Earning == null)
                totallEarning = 0;
            else
                totallEarning = (int)this.company.Earning;

            List<CompanyEntity> childCompanies = db.CompaniesTreeViewTable.Where(c => c.ParentId == company.Id).OrderBy(c => c.Name).ToList();
            foreach (CompanyEntity c in childCompanies)
                AddChild(new CompanyNode(this, c, db));
        }