Exemplo n.º 1
0
 private IMongoQuery <ArticleData> Query(NewsSearchConfiguration config)
 {
     return(new MongoQuery <ArticleData>(
                _newsFilterBuilder.BuildQuery(config),
                ProjectionDefinition(),
                _sortFactory.Make(config.SortType).AsMongoSortDefintion()));
 }
Exemplo n.º 2
0
        public IPaginatedResults <Article> SearchArticles(NewsSearchConfiguration config)
        {
            // TODO: This is a very basic temporary cache that does not consider search configuration

            if (_cache.Exists(Key))
            {
                return(_cache.Get <IPaginatedResults <Article> >(Key));
            }

            var value = _newsService.SearchArticles(config);

            _cache.Set(Key, value, new TimeSpan(1, 0, 0, 0));

            return(value);
        }
Exemplo n.º 3
0
 private IEnumerable <Article> ArticlesFromApi(NewsSearchConfiguration config)
 {
     return(_articleRepository.GetMany(Query(config))
            .Select(ToArticle)
            .ToList());
 }
Exemplo n.º 4
0
 public IPaginatedResults <Article> SearchArticles(NewsSearchConfiguration config)
 {
     return(_paginationService.Paginate(ArticlesFromApi(config), config.Page, PageSize));
 }
Exemplo n.º 5
0
 public IPaginatedResults <Article> SearchArticles(NewsSearchConfiguration config)
 {
     return(_paginationService.Paginate(TestArticles(), 1, PageSize));
 }