Esempio n. 1
0
        public async Task <IEnumerable <CategoryWithPathways> > GetCategoriesWithPathways()
        {
            var query = AllCategoriesQuery
                        .OptionalMatch("(category)-[:hasPathway]->(categorypathwaymd:PathwayMetaData)<-[:isDescribedAs]-(categorypathway:Pathway)")          // get the categories pathways and descriptions
                        .OptionalMatch("(subcategory)-[:hasPathway]->(subcategorypathwaymd:PathwayMetaData)<-[:isDescribedAs]-(subcategorypathway:Pathway)") // get the sub-categories pathways and descriptions
                        .Return(
                (category, categorypathway, categorypathwaymd, subcategory, subcategorypathway, subcategorypathwaymd) =>
                new CategoryPathwaysFlattened
            {
                Category         = category.As <Category>(),
                Pathways         = categorypathway.CollectAsDistinct <Pathway>(),
                PathwaysMetaData = categorypathwaymd.CollectAsDistinct <PathwayMetaData>()
            });

            var results    = await query.ResultsAsync;
            var categories = CategorisePathways(results);

            return(categories);
        }
Esempio n. 2
0
        public async Task <IEnumerable <Category> > GetCategories(string gender, int age)
        {
            var query = await AllCategoriesQuery
                        .OptionalMatch("(category)-[:hasPathway]->(md:PathwayMetaData)<-[:isDescribedAs]-(categorypathway:Pathway)")
                        .Where(string.Join(" and ", new List <string> {
                GenderIs(gender, "categorypathway"), AgeIsAboveMinimum(age, "categorypathway"), AgeIsBelowMaximum(age, "categorypathway")
            }))
                        .OptionalMatch("(subcategory)-[:hasPathway]->(md:PathwayMetaData)<-[:isDescribedAs]-(subcategorypathway:Pathway)")
                        .Where(string.Join(" and ", new List <string> {
                GenderIs(gender, "subcategorypathway"), AgeIsAboveMinimum(age, "subcategorypathway"), AgeIsBelowMaximum(age, "subcategorypathway")
            }))
                        .ReturnDistinct((category, subcategory) => new{ category = category.As <Category>(), subcategory = subcategory.As <Category>() })
                        .ResultsAsync;

            var categories    = query.Select(c => c.category);
            var subCategories = query.Select(c => c.subcategory);

            return(categories.Union(subCategories).Distinct(new CategoryComparer()));
        }
Esempio n. 3
0
        public async Task <IEnumerable <CategoryWithPathways> > GetCategoriesWithPathways(string gender, int age)
        {
            var query = AllCategoriesQuery
                        .OptionalMatch("(category)-[:hasPathway]->(categorypathwaymd:PathwayMetaData)<-[:isDescribedAs]-(categorypathway:Pathway)") // get the categories pathways and descriptions
                        .Where(string.Join(" and ",
                                           new List <string>
            {
                GenderIs(gender, "categorypathway"),
                AgeIsAboveMinimum(age, "categorypathway"),
                AgeIsBelowMaximum(age, "categorypathway")
            }))
                        .OptionalMatch("(subcategory)-[:hasPathway]->(subcategorypathwaymd:PathwayMetaData)<-[:isDescribedAs]-(subcategorypathway:Pathway)") // get the sub-categories pathways and descriptions
                        .Where(string.Join(" and ",
                                           new List <string>
            {
                GenderIs(gender, "subcategorypathway"),
                AgeIsAboveMinimum(age, "subcategorypathway"),
                AgeIsBelowMaximum(age, "subcategorypathway")
            }))
                        .Return(
                (category, categorypathway, categorypathwaymd, subcategory, subcategorypathway, subcategorypathwaymd)
                =>
                new CategoryPathwaysFlattened
            {
                Category                    = category.As <Category>(),
                Pathways                    = categorypathway.CollectAsDistinct <Pathway>(),
                PathwaysMetaData            = categorypathwaymd.CollectAsDistinct <PathwayMetaData>(),
                SubCategory                 = subcategory.As <Category>(),
                SubCategoryPathways         = subcategorypathway.CollectAsDistinct <Pathway>(),
                SubCategoryPathwaysMetaData = subcategorypathwaymd.CollectAsDistinct <PathwayMetaData>()
            });

            var results    = await query.ResultsAsync;
            var categories = CategorisePathways(results);

            return(categories);
        }