Ejemplo n.º 1
0
        public LinkedDataQuery(GenesRepository genesRepository,
                               ProteinsRepository proteinsRepository)
        {
            Name = "LinkedDataQuery";

            Field <GeneType>(
                "gene",
                arguments: new QueryArguments(new QueryArgument[]
            {
                new QueryArgument <StringGraphType> {
                    Name = "name"
                }
            }),
                resolve: context =>
            {
                var geneName = context.GetArgument <string>("name");
                return(genesRepository.Get((Gene gene) => gene.Name == geneName));
            });

            Field <ListGraphType <GeneType> >(
                "genes",
                resolve: context => genesRepository.GetAll());

            Field <ListGraphType <GeneWithRelationsType> >(
                "genesRelations",
                arguments: new QueryArguments(new QueryArgument[]
            {
                new QueryArgument <StringGraphType> {
                    Name = "geneName"
                }
            }),
                resolve: context =>
            {
                var geneName = context.GetArgument <string>("geneName");
                return(!string.IsNullOrEmpty(geneName)
                        ? genesRepository.GetTree((Gene gene) => gene.Name == geneName)
                        : genesRepository.GetTree());
            });

            Field <ListGraphType <ProteinWithRelationsType> >(
                "proteins",
                arguments: new QueryArguments(new QueryArgument[]
            {
                new QueryArgument <StringGraphType> {
                    Name = "geneName"
                }
            }),
                resolve: context =>
            {
                var geneName = context.GetArgument <string>("geneName");
                return(!string.IsNullOrEmpty(geneName)
                        ? proteinsRepository.GetTree((Gene gene) => gene.Name == geneName)
                        : proteinsRepository.GetTree());
            });
        }
Ejemplo n.º 2
0
 public GenesController(GenesRepository repository,
                        ProteinsRepository proteinsRepository)
 {
     _repository         = repository;
     _proteinsRepository = proteinsRepository;
 }