public async Task <IEnumerable <Data.Shared.Models.Synonym> > GetSynonymsByParentAsync(TaxonRank rank, string taxonName)
        {
            var childRank    = rank.GetChildRank();
            var synonymQuery = _synonymRepository.WhereWithIncludes(s => s.Rank == childRank.ToString() &&
                                                                    ((rank == TaxonRank.Kingdom && s.Taxon.Kingdom == taxonName) ||
                                                                     (rank == TaxonRank.Subkingdom && s.Taxon.Subkingdom == taxonName) ||
                                                                     (rank == TaxonRank.Infrakingdom && s.Taxon.Infrakingdom == taxonName) ||
                                                                     (rank == TaxonRank.Phylum && s.Taxon.Phylum == taxonName) ||
                                                                     (rank == TaxonRank.Subphylum && s.Taxon.Subphylum == taxonName) ||
                                                                     (rank == TaxonRank.Class && s.Taxon.Class == taxonName) ||
                                                                     (rank == TaxonRank.Subclass && s.Taxon.Subclass == taxonName) ||
                                                                     (rank == TaxonRank.Superorder && s.Taxon.Superorder == taxonName) ||
                                                                     (rank == TaxonRank.Order && s.Taxon.Order == taxonName) ||
                                                                     (rank == TaxonRank.Suborder && s.Taxon.Suborder == taxonName) ||
                                                                     (rank == TaxonRank.Family && s.Taxon.Family == taxonName) ||
                                                                     (rank == TaxonRank.Subfamily && s.Taxon.Subfamily == taxonName) ||
                                                                     (rank == TaxonRank.Genus && s.Taxon.Genus == taxonName) ||
                                                                     (rank == TaxonRank.Species && s.Taxon.Species == taxonName) ||
                                                                     (rank == TaxonRank.Subspecies && s.Taxon.Subspecies == taxonName) ||
                                                                     (rank == TaxonRank.Variety && s.Taxon.Subvariety == taxonName) ||
                                                                     (rank == TaxonRank.Subkingdom && s.Taxon.Subkingdom == taxonName)),
                                                                    false,
                                                                    s => s.Include(s => s.Taxon));

            var synonymResult = synonymQuery.GetSomeAsync();
            var synonyms      = new List <Data.Shared.Models.Synonym>();

            await foreach (var synonym in synonymResult)
            {
                synonyms.Add(synonym.AsModel());
            }
            return(synonyms);
        }
Exemple #2
0
        public async Task NavigateAsync(TaxonRank rank)
        {
            // we click on class we should get subclass
            // currently getting class
            var crumb = Breadcrumbs[rank];

            Breadcrumbs = Breadcrumbs.Where(b => b.Key <= rank).ToDictionary(b => b.Key, b => b.Value);
            Shape       = crumb.Copy();
            Rank        = rank.GetChildRank();
            foreach (var breadcrumb in Breadcrumbs)
            {
                Console.WriteLine(breadcrumb.GetHashCode());
            }

            Console.WriteLine(Shape.GetHashCode());
            await SearchAsync();
        }
Exemple #3
0
        public async Task SearchAsync(TaxonRank rank, string name)
        {
            if (Shape != null && !Breadcrumbs.ContainsKey(rank))
            {
                Breadcrumbs.Add(Rank, Shape.Copy());
            }

            switch (rank)
            {
            case TaxonRank.Kingdom:
                Shape.Kingdom = name;
                break;

            case TaxonRank.Subkingdom:
                Shape.Subkingdom = name;
                break;

            case TaxonRank.Infrakingdom:
                Shape.Infrakingdom = name;
                break;

            case TaxonRank.Phylum:
                Shape.Phylum = name;
                break;

            case TaxonRank.Subphylum:
                Shape.Subphylum = name;
                break;

            case TaxonRank.Class:
                Shape.Class = name;
                break;

            case TaxonRank.Subclass:
                Shape.Subclass = name;
                break;

            case TaxonRank.Superorder:
                Shape.Superorder = name;
                break;

            case TaxonRank.Order:
                Shape.Order = name;
                break;

            case TaxonRank.Suborder:
                Shape.Suborder = name;
                break;

            case TaxonRank.Family:
                Shape.Family = name;
                break;

            case TaxonRank.Subfamily:
                Shape.Subfamily = name;
                break;

            case TaxonRank.Genus:
                Shape.Genus = name;
                break;

            case TaxonRank.Species:
                Shape.Species = name;
                break;
            }

            Rank = rank.GetChildRank();

            Breadcrumbs[rank] = Shape.Copy();

            await SearchAsync();
        }