/// <summary> /// Creates a search result item from a Taxon object. /// </summary> /// <param name="taxon">The taxon.</param> /// <returns></returns> public static TaxonSearchResultItemViewModel CreateFromTaxon(ITaxon taxon, bool useIdAsSearchMatching = true) { var model = new TaxonSearchResultItemViewModel(); model.NameCategory = "TaxonId"; model.Author = taxon.Author.IsNotEmpty() ? taxon.Author : ""; model.TaxonId = taxon.Id; model.SearchMatchName = useIdAsSearchMatching ? taxon.Id.ToString() : taxon.CommonName.IsNotEmpty() ? taxon.CommonName : taxon.ScientificName; model.ScientificName = taxon.ScientificName.IsNotEmpty() ? taxon.ScientificName : ""; model.CommonName = taxon.CommonName.IsNotEmpty() ? taxon.CommonName : ""; model.Category = taxon.Category != null ? taxon.Category.Name : ""; model.TaxonStatus = (TaxonAlertStatusId)taxon.AlertStatus.Id; return(model); }
/// <summary> /// Creates a search result item from an ITaxonName. /// </summary> /// <param name="taxonName">Taxon name object.</param> /// <returns></returns> public static TaxonSearchResultItemViewModel CreateFromTaxonName(ITaxonName taxonName) { var model = new TaxonSearchResultItemViewModel(); ITaxon taxon = taxonName.Taxon; model.NameCategory = taxonName.Category.Name; model.Author = taxon.Author.IsNotEmpty() ? taxon.Author : ""; model.TaxonId = taxonName.Taxon.Id; model.SearchMatchName = taxonName.Name; model.ScientificName = taxon.ScientificName.IsNotEmpty() ? taxon.ScientificName : ""; model.CommonName = taxon.CommonName.IsNotEmpty() ? taxon.CommonName : ""; model.Category = taxon.Category != null ? taxon.Category.Name : ""; model.TaxonStatus = (TaxonAlertStatusId)taxon.AlertStatus.Id; return(model); }
protected bool Equals(TaxonSearchResultItemViewModel other) { return(TaxonId == other.TaxonId && string.Equals(ScientificName, other.ScientificName) && string.Equals(CommonName, other.CommonName) && string.Equals(SearchMatchName, other.SearchMatchName) && string.Equals(Category, other.Category) && string.Equals(Author, other.Author) && string.Equals(NameCategory, other.NameCategory) && TaxonStatus == other.TaxonStatus); }