コード例 #1
0
ファイル: Youtube.cs プロジェクト: h0lg/SubTubular
        /// <summary>Searches videos according to the specified command.</summary>
        /// <param name="cancellation">Passed in either explicitly or by the IAsyncEnumerable.WithCancellation() extension,
        /// see https://docs.microsoft.com/en-us/archive/msdn-magazine/2019/november/csharp-iterating-with-async-enumerables-in-csharp-8#a-tour-through-async-enumerables</param>
        internal async IAsyncEnumerable <VideoSearchResult> SearchVideosAsync(
            SearchVideos command, [EnumeratorCancellation] CancellationToken cancellation = default)
        {
            foreach (var videoId in command.GetVideoIds())
            {
                cancellation.ThrowIfCancellationRequested();
                var video = await GetVideoAsync(videoId, cancellation);

                var searchResult = SearchVideo(video, command.Terms);
                if (searchResult != null)
                {
                    yield return(searchResult);
                }
            }
        }
コード例 #2
0
        public IActionResult Index([FromQuery] SearchVideos dto)
        {
            int         TotalItems     = 0;
            string      ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            VideosModel data           = new VideosModel()
            {
                SearchData = dto
            };

            data.ListItems = VideosService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName);
            if (data.ListItems != null && data.ListItems.Count() > 0)
            {
                TotalItems = data.ListItems[0].TotalRows;
            }
            data.Pagination = new API.Areas.Admin.Models.Partial.PartialPagination()
            {
                CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString()
            };
            return(View(data));
        }