public WaterfallContext() { ClientUniqueID = 0; ClientID = ""; ClientName = ""; ReportDataSetID = 0; ProjectName = ""; ProjectsMaxLevel = 0; SelectedProjectsLevel = 0; SelectedOrganizations = new TreeListChecks(); SelectedProjects = new TreeListChecks(); SelectedFiscalYears = new List <string>(); SelectedDemographics = new List <string>(); RevenueAccounts = new SelectedRevenueAccounts(); CostsAccounts = new SelectedCostsAccounts(); }
public static List <Project> ProcessSelectedOrganizationsIntoProjects(IEnumerable <Project> fullList, TreeListChecks checks) { List <Project> result = new List <Project>(); //if All Active are selected, add them if (checks.SelectAllActive) { result.AddRange(fullList.Where(x => x.ActiveFlag == "Y").ToList()); } //if All Inactive are selected, add them if (checks.SelectAllInactive) { result.AddRange(fullList.Where(x => x.ActiveFlag == "N").ToList()); } //Add All that start with foreach (var el in checks.CheckedNodes) { result.AddRange(fullList.Where(x => x.OrgId.StartsWith(el)).ToList()); } foreach (var el in checks.VisibleUncheckedNodes) { //if there are checked children of the element, remove the parent only if (checks.CheckedNodes.Where(x => x.StartsWith(el)).Count() > 0) { result.RemoveAll(x => x.Id == el); } //otherwise, remove parent and all children else { result.RemoveAll(x => x.Id.StartsWith(el)); } } return(result.Distinct().ToList()); }