Exemple #1
0
        public JsonResult GetScientificName(string name)
        {
            WikipediaReader wikipediaRaeder = new WikipediaReader();
            string          scientificName  = wikipediaRaeder.GetScientificName(name);

            return(Json(scientificName));
        }
Exemple #2
0
        private static Taxon GetOrCreateGenus(string genusName, SubjectManager subjectManager)
        {
            WikipediaReader wReader = new WikipediaReader();

            Taxon genus = new Taxon();

            if (subjectManager.GetAll <Taxon>().Any(s => s.ScientificName.Equals(genusName)))
            {
                genus = subjectManager.GetAll <Taxon>().FirstOrDefault(s => s.ScientificName.Equals(genusName));

                if (string.IsNullOrEmpty(genus.Name) && !string.IsNullOrEmpty(genus.ScientificName))
                {
                    genus.Name = wReader.GetName(genus.ScientificName);
                }

                if (string.IsNullOrEmpty(genus.ScientificName) && !string.IsNullOrEmpty(genus.Name))
                {
                    genus.ScientificName = wReader.GetScientificName(genus.Name);
                }
            }
            else
            {
                genus.ScientificName = genusName;
                genus.Name           = wReader.GetName(genusName);

                if (String.IsNullOrEmpty(genus.Name))
                {
                    genus.Name = genusName;
                }

                genus.Rank = TaxonRank.Genus;

                subjectManager.Create(genus);
            }

            return(genus);
        }