public List <HierarchicalViewModelBase> LoadModel(HierarchicalViewModelBase parent)
        {
            var          service = new TaxaService(User);
            List <Taxon> model   = null;

            if (parent == null)
            {
                model = service.GetTopLevelTaxa();
            }
            else
            {
                model = service.GetTaxaForParent((parent as TaxonViewModel).TaxaID.Value);
            }

            if (model != null)
            {
                var temp = model.Where((taxon) => {
                    return(_options == LookupOptions.TaxonExcludeAvailableNames ? !taxon.AvailableName.ValueOrFalse() : true);
                }).Select((m) => {
                    return(new TaxonViewModel(parent, m, _explorer.GenerateTaxonDisplayLabel));
                });

                var list = new List <HierarchicalViewModelBase>(temp);
                return(list);
            }

            return(null);
        }
コード例 #2
0
        private void BuildTaxaChildrenViewModel(HierarchicalViewModelBase item, int taxaID)
        {
            // The model node is a Taxon favorites, so we can get the 'real' taxon children for it...
            item.Children.Clear();

            var          taxaService = new TaxaService(User);
            List <Taxon> taxa        = taxaService.GetTaxaForParent(taxaID);

            foreach (Taxon taxon in taxa)
            {
                TaxonViewModel child = new TaxonViewModel(item, taxon, null);
                if (child.NumChildren > 0)
                {
                    child.LazyLoadChildren += new HierarchicalViewModelAction(viewModel_LazyLoadChildren);
                    child.Children.Add(new ViewModelPlaceholder("Loading..."));
                }
                item.Children.Add(child);
            }
        }