/// <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); }
public MatchSettingsViewModel() { this.LabelForProvidedText = Resources.DyntaxaResource.MatchOptionsOutputProvidedTextLabel; _searchOptions = new TaxonSearchOptions(); _searchOptions.DefaultNameCompareOperator = DyntaxaStringCompareOperator.Equal; _searchOptions.NameCompareOperator = DyntaxaStringCompareOperator.Equal; _searchOptions.HideAuthorTextbox = true; }