コード例 #1
0
        public async Task <IEnumerable <FeedDto> > GetFeedAsync(SearchFeedQuery query, CancellationToken token)
        {
            var itemsTask  = _documentFeedService.GetFeedAsync(query, token);
            var tutorsTask = _tutorFeedService.GetFeedAsync(query, token);

            await Task.WhenAll(itemsTask, tutorsTask);

            return(SortFeed(itemsTask.Result.ToList(),
                            tutorsTask.Result.ToList(),
                            query.Page));
        }
コード例 #2
0
        public async Task <IEnumerable <FeedDto> > GetFeedAsync(SearchFeedQuery query, CancellationToken token)
        {
            string termToQuery;

            if (!string.IsNullOrEmpty(query.Course))
            {
                termToQuery = $"{query.Term} {query.Course}".Trim();
            }
            else
            {
                termToQuery = query.Term.Trim();
            }
            var tutorQuery = new TutorListTabSearchQuery(termToQuery, query.Country, query.Page, _pageSize);

            return(await _tutorSearch.SearchAsync(tutorQuery, token).ContinueWith(r => r.Result.Result, token));
        }
コード例 #3
0
        public async Task <IEnumerable <FeedDto> > GetFeedAsync(SearchFeedQuery query, CancellationToken token)
        {
            DocumentType?filter = null;

            switch (query.Filter)
            {
            case FeedType.Document:
                filter = DocumentType.Document;
                break;

            case FeedType.Video:
                filter = DocumentType.Video;
                break;
                //default:
                //    //throw new ArgumentOutOfRangeException();
            }
            var documentQuery = new DocumentQuery(query.Profile, query.Term, query.Course, query.Page, _pageSize, filter);

            return(await _searchProvider.SearchDocumentsAsync(documentQuery, token));
        }
コード例 #4
0
        public async Task <IEnumerable <FeedDto> > GetFeedAsync(SearchFeedQuery query, CancellationToken token)
        {
            if (query is null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            return(await _services[query.Filter].GetFeedAsync(query, token));


            //if (query is null)
            //{
            //    throw new ArgumentNullException(nameof(query));
            //}

            //string termToQuery;
            //if (!string.IsNullOrEmpty(query.Course))
            //{
            //    termToQuery = $"{query.Term} {query.Course}".Trim();
            //}
            //else
            //{
            //    termToQuery = query.Term.Trim();
            //}
            //var feedQuery = new DocumentQuery(query.Profile, query.Term, query.Course, ItemPageSize, query.Filter);
            ////if (query.Filter == null)
            ////{
            ////    var feedQuery = new DocumentQuery(query.Profile, termToQuery, query.Course, ItemPageSize, query.Filter)
            ////    {
            ////        Page = query.Page,
            ////    };
            ////}
            //var tutorQuery = new TutorListTabSearchQuery(termToQuery, query.Country, query.Page, TutorPageSize);
            //var tutorTask = _tutorSearch.SearchAsync(tutorQuery, token);
            //var resultTask = _searchProvider.SearchDocumentsAsync(feedQuery, token);


            //await Task.WhenAll(resultTask, tutorTask);
            //var result = SortFeed(resultTask.Result?.ToList(), tutorTask.Result?.Result?.ToList(), query.Page);
            //return result;


            //if (query.Filter == Core.Enum.FeedType.Tutor)
            //{
            //    var tutorQuery = new TutorListTabSearchQuery(termToQuery, query.Country, query.Page, 21);
            //    var tutorsTask = _tutorSearch.SearchAsync(tutorQuery, token);
            //    await Task.WhenAll(tutorsTask);
            //    return tutorsTask.Result;
            //}

            //if (query.Filter == Core.Enum.FeedType.Document || query.Filter == Core.Enum.FeedType.Video)
            //{
            //    var feedQuery = new DocumentQuery(query.Profile, termToQuery, query.Course, 21, query.Filter)
            //    {
            //        Page = query.Page,
            //    };
            //    var resultTask = _searchProvider.SearchDocumentsAsync(feedQuery, token);
            //    await Task.WhenAll(resultTask);
            //    //Query docs/video
            //    return resultTask.Result;
            //}

            //return Enumerable.Empty<FeedDto>();
        }
コード例 #5
0
 public Task <IEnumerable <FeedDto> > GetFeedAsync(SearchFeedQuery query, CancellationToken token)
 {
     return(Task.FromResult(Enumerable.Empty <FeedDto>()));
 }