Esempio n. 1
0
        public AppQuery(
            IAuthorService authorService,
            IPodcastService podcastService,
            IEpisodeService episodeService
            )
        {
            Field <ListGraphType <AuthorType> >(
                "authors",
                resolve: context => authorService.GetAll()
                );

            Field <AuthorType>(
                "author",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "id"
            }
                    ),
                resolve: context => {
                var id = context.GetArgument <int>("id");
                return(authorService.GetAuthorById(id));
            }
                );

            Field <ListGraphType <PodcastType> >(
                "podcasts",
                resolve: context => podcastService.GetAll()
                );

            Field <PodcastType>(
                "podcast",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "id"
            }
                    ),
                resolve: context => {
                var id = context.GetArgument <int>("id");
                return(podcastService.GetPodcastById(id));
            }
                );

            Field <ListGraphType <EpisodeType> >(
                "episodes",
                resolve: context => episodeService.GetAll()
                );

            Field <EpisodeType>(
                "episode",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "id"
            }
                    ),
                resolve: context => {
                var id = context.GetArgument <int>("id");
                return(episodeService.GetEpisodeById(id));
            }
                );
        }
Esempio n. 2
0
 public Query(ICharacterService characterService, IEpisodeService episodeService)
 {
     Name = "Query";
     // Expose characters
     Field <ListGraphType <CharacterType> >("characters", resolve: (context) => characterService.GetAll());
     // Expose episodes
     Field <ListGraphType <EpisodeType> >("episodes", resolve: (context) => episodeService.GetAll());
 }
Esempio n. 3
0
        public async Task <EpisodeRoot> GetAll()
        {
            try
            {
                return(await _episodeService.GetAll());
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            return(null);
        }
Esempio n. 4
0
        private static async Task <IEnumerable <Episode> > GetAllEpisodesForCharacter(IEpisodeService episodeService, string characterName)
        {
            var allEpisodes = await episodeService.GetAll();

            return(allEpisodes.Where(e => e.scenes.SelectMany(s => s.characters).Any(c => c.name == characterName)));
        }