Ejemplo n.º 1
0
        public static void BuildDpVM_TreeStructs(this ObservableCollection <DepartmentViewModel> topDpvms, IEnumerable <Department> DpsSource, DepartmentViewModel parentDpvm = null, DepartmentManagerViewModel dpMgVm = null)
        {
            var foundChildren = DpsSource.ToList().FindAll(d => d.ParentDepartment == (parentDpvm == null ? null : parentDpvm.Model));

            foreach (var childDp in foundChildren)
            {
                var childDpvm = new DepartmentViewModel(childDp, dpMgVm);
                var from      = childDpvm;
                var to        = parentDpvm;
                if (to == null)
                {
                    topDpvms.Add(from);
                }
                else
                {
                    to.AddChildDepartment(from);
                }
                //AddDpvm(childDpvm, parentDpvm);
                topDpvms.BuildDpVM_TreeStructs(DpsSource, childDpvm, dpMgVm);
            }
        }
Ejemplo n.º 2
0
 public DepartmentViewModel(Department model, DepartmentManagerViewModel parentvm)
     : base(model)
 {
     _parentManagerVM = parentvm;
     ChildrenDpvms    = new ObservableCollection <DepartmentViewModel>();
 }