/// <summary>
        /// Searches for taxa using the give search options.
        /// </summary>
        /// <param name="searchOptions">The search options to use in the search.</param>
        /// <returns></returns>
        public List <TaxonSearchResultItemViewModel> SearchTaxa(TaxonSearchOptions searchOptions)
        {
            TaxonNameSearchCriteria taxonNameSearchCriteria = searchOptions.CreateTaxonNameSearchCriteriaObject();
            TaxonNameList           taxonNames = CoreData.TaxonManager.GetTaxonNames(_user, taxonNameSearchCriteria);
            ITaxon taxonFoundById = SearchTaxonById(searchOptions.NameSearchString);
            var    resultList     = new List <TaxonSearchResultItemViewModel>();

            if (taxonFoundById != null) // the user entered a valid taxonid as search string
            {
                resultList.Add(TaxonSearchResultItemViewModel.CreateFromTaxon(taxonFoundById));
            }
            for (int i = 0; i < taxonNames.Count; i++)
            {
                resultList.Add(TaxonSearchResultItemViewModel.CreateFromTaxonName(taxonNames[i]));
            }
            resultList = resultList.Distinct().ToList();

            SpeciesFactManager speciesFactManager = new SpeciesFactManager(_user);

            IEnumerable <ITaxon> protectedTaxonList = speciesFactManager.GetProtectedTaxons();

            // Set protection level for each taxon; public or not
            resultList.ForEach(t => t.SpeciesProtectionLevel = protectedTaxonList.Any(ptl => ptl.Id == t.TaxonId) ? SpeciesProtectionLevelEnum.Protected1 : SpeciesProtectionLevelEnum.Public);

            return(resultList);
        }
        /// <summary>
        /// Search taxa by factor fields.
        /// </summary>
        /// <param name="taxonSearchFactorFieldViewModels">List of factor fields with properties.</param>
        /// <param name="factorId"></param>
        /// <param name="restrictToCurrentTaxonFilter"></param>
        /// <param name="settings"></param>
        public List <TaxonSearchResultItemViewModel> SearchTaxa(List <TaxonSearchFactorFieldViewModel> taxonSearchFactorFieldViewModels, Int32 factorId, Boolean restrictToCurrentTaxonFilter, MySettings.MySettings settings)
        {
            var resultList = new List <TaxonSearchResultItemViewModel>();

            List <ITaxon> taxons = SearchTaxonByFactor(taxonSearchFactorFieldViewModels, factorId, restrictToCurrentTaxonFilter, settings);

            foreach (var taxon in taxons)
            {
                resultList.Add(TaxonSearchResultItemViewModel.CreateFromTaxon(taxon));
            }

            SpeciesFactManager speciesFactManager = new SpeciesFactManager(_user);

            IEnumerable <ITaxon> protectedTaxonList = speciesFactManager.GetProtectedTaxons();

            // Set protection level for each taxon; public or not
            resultList.ForEach(t => t.SpeciesProtectionLevel = protectedTaxonList.Any(ptl => ptl.Id == t.TaxonId) ? SpeciesProtectionLevelEnum.Protected1 : SpeciesProtectionLevelEnum.Public);

            return(resultList);
        }
        /// <summary>
        /// Get all child taxon
        /// </summary>
        /// <param name="parentTaxaIds">Id of parent taxon</param>
        /// <returns></returns>
        public List <TaxonSearchResultItemViewModel> GetChildTaxa(int[] parentTaxaIds)
        {
            var searchCriteria = new TaxonSearchCriteria()
            {
                TaxonIds         = new List <int>(parentTaxaIds),
                TaxonCategoryIds = new List <int> {
                    (int)TaxonCategoryId.Species
                },
                Scope = TaxonSearchScope.AllChildTaxa
            };

            var taxa       = CoreData.TaxonManager.GetTaxa(_user, searchCriteria);
            var resultList = (from t in taxa select TaxonSearchResultItemViewModel.CreateFromTaxon(t, false)).Distinct().ToList();

            var speciesFactManager = new SpeciesFactManager(_user);

            var protectedTaxonList = speciesFactManager.GetProtectedTaxons();

            // Set protection level for each taxon; public or not
            resultList.ForEach(t => t.SpeciesProtectionLevel = protectedTaxonList.Any(ptl => ptl.Id == t.TaxonId) ? SpeciesProtectionLevelEnum.Protected1 : SpeciesProtectionLevelEnum.Public);

            return(resultList);
        }