/// <summary> /// Init red list information. /// </summary> /// <param name="taxonSpeciesFact">Taxon species fact view model.</param> /// <param name="categorySpeciesFact">Red list category species fact.</param> /// <param name="criteriaSpeciesFact">Red list criteria species fact.</param> /// <param name="criteriaDocumentationSpeciesFact">Red list criteria documentation species fact.</param> /// <param name="globalCategorySpeciesFact">Global red list category species fact.</param> /// <param name="period">Red list period.</param> public static void InitRedListInformation( TaxonSpeciesFactViewModel taxonSpeciesFact, ISpeciesFact categorySpeciesFact, ISpeciesFact criteriaSpeciesFact, ISpeciesFact criteriaDocumentationSpeciesFact, ISpeciesFact globalCategorySpeciesFact, IPeriod period) { if (categorySpeciesFact.IsRedlistCategorySpecified()) { taxonSpeciesFact.RedListCategory = categorySpeciesFact.Field1.EnumValue.OriginalLabel.Substring(0, categorySpeciesFact.Field1.EnumValue.OriginalLabel.Length - 4) + "(" + categorySpeciesFact.MainField.StringValue + ")"; taxonSpeciesFact.IsRedListed = categorySpeciesFact.Field1.EnumValue.KeyInt >= (int)RedListCategory.DD && categorySpeciesFact.Field1.EnumValue.KeyInt < (int)RedListCategory.LC; taxonSpeciesFact.IsRedListCriteriaAvailable = (categorySpeciesFact.Field1.EnumValue.KeyInt >= (int)RedListCategory.CR) && (categorySpeciesFact.Field1.EnumValue.KeyInt <= (int)RedListCategory.VU); } if (taxonSpeciesFact.IsRedListCriteriaAvailable && criteriaSpeciesFact.IsRedlistCriteriaSpecified()) { taxonSpeciesFact.RedListCriteria = criteriaSpeciesFact.MainField.StringValue; } if (globalCategorySpeciesFact.IsGlobalRedlistCategorySpecified()) { taxonSpeciesFact.GlobalRedListCategory = globalCategorySpeciesFact.MainField.StringValue; } if (criteriaDocumentationSpeciesFact.IsRedlistDocumentationSpecified()) { taxonSpeciesFact.RedListDocumentationQuality = criteriaDocumentationSpeciesFact.Quality.Id; taxonSpeciesFact.RedListDocumentationText = criteriaDocumentationSpeciesFact.MainField.StringValue; } taxonSpeciesFact.Period = period.Year; }
/// <summary> /// Set species fact information about this taxon. /// </summary> /// <param name="speciesFact">Species fact with red list information.</param> public void SetSpeciesFact(ISpeciesFact speciesFact) { if (LandscapeTypeManager.LandscapeTypeFactors.IsNotNull() && LandscapeTypeManager.LandscapeTypeFactors.Exists(speciesFact.Factor)) { if (speciesFact.IsLandscapeTypeOccurrenceSpecified()) { string landscapeTypeOccurrence = speciesFact.Factor.Label; landscapeTypeOccurrence = landscapeTypeOccurrence.Substring(landscapeTypeOccurrence.Length - 2, 1); switch (speciesFact.MainField.EnumValue.KeyInt) { case (int)LandscapeTypeImportanceEnum.HasImportance: LandscapeTypeOccurrence += landscapeTypeOccurrence.ToLower(); break; case (int)LandscapeTypeImportanceEnum.VeryImportant: LandscapeTypeOccurrence += landscapeTypeOccurrence.ToUpper(); break; } } } else { switch (speciesFact.Factor.Id) { case (int)FactorId.RedlistCategory: if (speciesFact.IsRedlistCategorySpecified()) { RedListCategory = speciesFact.Field1.EnumValue.OriginalLabel.Substring(0, speciesFact.Field1.EnumValue.OriginalLabel.Length - 4) + "(" + speciesFact.MainField.StringValue + ")"; var category = (RedListCategory)Enum.Parse(typeof(RedListCategory), RedListCategory.Substring(RedListCategory.IndexOf("(", StringComparison.Ordinal) + 1, 2)); IsRedListed = RedListedHelper.IsRedListedDdToNt((int)category); IsRedListedEnsured = RedListedHelper.IsRedListedDdToNe((int)category); RedListCategoryId = Convert.ToInt32(speciesFact.Field1.EnumValue.KeyInt); } break; case (int)FactorId.RedlistCriteriaString: if (speciesFact.IsRedlistCriteriaSpecified()) { RedListCriteria = speciesFact.MainField.StringValue; } break; case (int)FactorId.Redlist_OrganismLabel1: if (speciesFact.IsOrganismGroupSpecified()) { if (OrganismGroup.IsEmpty()) { OrganismGroup = speciesFact.MainField.EnumValue.OriginalLabel; } else { if (OrganismGroup != speciesFact.MainField.EnumValue.OriginalLabel) { OrganismGroup = speciesFact.MainField.EnumValue.OriginalLabel + ", " + OrganismGroup; } } } break; case (int)FactorId.SwedishOccurrence: if (speciesFact.IsSwedishOccurrenceSpecified()) { SwedishOccurrence = speciesFact.MainField.EnumValue.OriginalLabel; SwedishOccurrenceId = Convert.ToInt32(speciesFact.MainField.EnumValue.KeyInt); } break; } } }