Ejemplo n.º 1
0
        public async Task <IEnumerable <FeedDto> > SearchDocumentsAsync(DocumentQuery query,
                                                                        CancellationToken token)
        {
            var searchResult = await _client.SearchAsync(query, query.UserProfile, token);

            var documentResult = searchResult.result.ToList();
            var ids            = documentResult.Select(s => s.Id);
            var queryDb        = new IdsDocumentsQuery(ids);
            var dbResult       = await _queryBus.QueryAsync(queryDb, token);

            var dic = dbResult.ToDictionary(x => x.Id);



            var retVal = new List <DocumentFeedDto>();

            foreach (var resultResult in documentResult)
            {
                if (dic.TryGetValue(resultResult.Id, out var p))
                {
                    //p.Source = "Cloudents";
                    retVal.Add(p);
                }
            }

            return(retVal);
        }
Ejemplo n.º 2
0
        public async Task DocumentSearch_Params_Ok(string country, string term, string course, DocumentType?filter)
        {
            var userProfile = new UserProfile()
            {
                Country = country
            };
            var query        = new DocumentQuery(userProfile, term, course, 0, 20, filter);
            var searchResult = await _client.SearchAsync(query, userProfile, default);

            var documentResult = searchResult.result.ToList();
            var ids            = documentResult.Select(s => s.Id);
            var queryDb        = new IdsDocumentsQuery(ids);
            var dbResult       = await _queryBus.QueryAsync(queryDb, default);

            if (dbResult.Count > 0)
            {
                dbResult.Should().OnlyContain(o => o.Course == course);
            }
        }