Exemplo n.º 1
0
        public async Task <IActionResult> Get([FromQuery] YoutubeMovieTrailerQuery query)
        {
            var movieList = await mediator.Send(query);

            queue.QueueBackgroundWorkItem((token) => mediator.Send(new SaveOrUpdateMovieTrailerCommand(movieList), token));
            return(Ok(movieList));
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <MovieTrailer> > Handle(YoutubeMovieTrailerQuery request, CancellationToken cancellationToken)
        {
            var searchResult = await httpClient
                               .GetAsync <SearchResultModel>(youtubeSettings.Value.ApiUrl +
                                                             $"&maxResults={request.ItemsPerPage}&q={request.Search}");

            return(searchResult.Items.Select(item => new MovieTrailer()
            {
                Link = string.Concat(youtubeSettings.Value.WatchUrl, item.Id.VideoId),
                Title = item.Snippet.Title,
                Provider = Youtube
            }));
        }