/// <summary>
        /// Creates a TaxonMove view model
        /// </summary>
        /// <param name="taxon"></param>
        /// <param name="isOkToMove"></param>
        /// <returns></returns>
        public TaxonMoveViewModel CreateTaxonMoveViewModel(ITaxon taxon, ITaxonRevision taxonRevision, bool isOkToMove = true)
        {
            var model = new TaxonMoveViewModel();

            model.TaxonId          = taxon.Id;
            model.OldParentTaxonId = taxon.Id;
            model.HasChildren      = true;
            model.IsOkToMove       = isOkToMove;

            // Child taxa
            model.ChildTaxa = new List <RelatedTaxonViewModel>();
            if (taxon.GetNearestChildTaxonRelations(_user).IsNotEmpty())
            {
                foreach (ITaxonRelation taxonRelation in taxon.GetNearestChildTaxonRelations(_user))
                {
                    model.ChildTaxa.Add(new RelatedTaxonViewModel(taxonRelation.ChildTaxon, taxonRelation.ChildTaxon.Category, null, taxonRelation.IsMainRelation));
                }
            }
            if (model.ChildTaxa.Count == 0)
            {
                // TODO cant throw exception
                //throw new Exception("Taxon has no children");
                model.HasChildren = false;
            }

            // Available parents
            TaxonCategoryList categories2 = new TaxonCategoryList();

            model.AvailableParents = new List <RelatedTaxonViewModel>();
            if (model.ChildTaxa.Count != 0)
            {
                ITaxon    revisionTaxon = CoreData.TaxonManager.GetTaxon(_user, model.ChildTaxa[0].TaxonId);
                TaxonList list          = revisionTaxon.GetTaxaPossibleParents(_user, taxonRevision);
                foreach (var tx in list)
                {
                    categories2.Merge(tx.Category);
                }
                categories2.Sort(new TaxonCategoryComparer());

                foreach (ITaxon possibleParentTaxon in list)
                {
                    model.AvailableParents.Add(new RelatedTaxonViewModel(possibleParentTaxon, possibleParentTaxon.Category, null));
                }
            }

            // Taxon categories
            model.TaxonCategories = new List <TaxonCategoryViewModel>();
            // var categories = GetTaxonCategories(taxon);
            // Get all categories within this revision
            TaxonCategoryList categories = GetTaxonCategories(taxonRevision.RootTaxon);

            foreach (ITaxonCategory taxonCategory in categories2)
            {
                model.TaxonCategories.Add(new TaxonCategoryViewModel(taxonCategory.Id, taxonCategory.Name));
            }

            return(model);
        }
        public void ReInitializeTaxonMoveViewModel(TaxonMoveViewModel model, ITaxonRevision taxonRevision, bool isOkToMove = true) //, ITaxon taxon, bool isOkToMove = true)
        {
            ITaxon taxon = CoreData.TaxonManager.GetTaxon(_user, model.OldParentTaxonId);

            model.HasChildren = true;
            model.IsOkToMove  = isOkToMove;

            // Child taxa
            model.ChildTaxa = new List <RelatedTaxonViewModel>();
            if (taxon.GetNearestChildTaxonRelations(_user).IsNotEmpty())
            {
                foreach (ITaxonRelation taxonRelation in taxon.GetNearestChildTaxonRelations(_user))
                {
                    model.ChildTaxa.Add(new RelatedTaxonViewModel(taxonRelation.ChildTaxon, taxonRelation.ChildTaxon.Category, null));
                }
            }
            if (model.ChildTaxa.Count == 0)
            {
                // TODO cant throw exception
                //throw new Exception("Taxon has no children");
                model.HasChildren = false;
            }

            // Available parents
            model.AvailableParents = new List <RelatedTaxonViewModel>();
            if (model.ChildTaxa.Count != 0)
            {
                ITaxon    revisionTaxon = CoreData.TaxonManager.GetTaxon(_user, model.ChildTaxa[0].TaxonId);
                TaxonList list          = revisionTaxon.GetTaxaPossibleParents(_user, taxonRevision);
                foreach (ITaxon possibleParentTaxon in list)
                {
                    model.AvailableParents.Add(new RelatedTaxonViewModel(possibleParentTaxon, possibleParentTaxon.Category, null));
                }
            }

            // Taxon categories
            model.TaxonCategories = new List <TaxonCategoryViewModel>();
            // var categories = GetTaxonCategories(taxon);
            // Get all categories within this revision
            var categories = GetTaxonCategories(taxonRevision.RootTaxon);

            foreach (ITaxonCategory taxonCategory in categories)
            {
                model.TaxonCategories.Add(new TaxonCategoryViewModel(taxonCategory.Id, taxonCategory.Name));
            }
        }