private void AddChild(CompanyNode child) { if (childs == null) childs = new List<CompanyNode>(); childs.Add(child); if (child.company.Earning != null) AddValueToEarning((int)child.company.Earning); }
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)); }