Example #1
0
        public ArticlesController(
            IOptions <ArticlesOptions> articlesOptions,
            IAuthorizationService authorizationService,
            ICategoriesCache categoriesCache,
            OperationKeysContainer operationKeysContainer,
            IArticlesPresenter articlesPresenter,
            IServiceProvider serviceProvider) : base(serviceProvider)
        {
            OperationKeys = operationKeysContainer;

            this.articlesOptions      = articlesOptions.Value;
            this.authorizationService = authorizationService;
            this.categoriesCache      = categoriesCache;
            this.articlesPresenter    = articlesPresenter;
        }
Example #2
0
        public async Task <IActionResult> GetArticles([FromQuery] int pageNumber, [FromQuery] ArticlesOptions articlesOptions)
        {
            var articles = await feedService.GetArticles(pageNumber == 0? 1 : pageNumber, appSettings.Value.PageSize, articlesOptions);

            return(Ok(articles));
        }
Example #3
0
        public async Task <ArticlePageList> GetArticles(int pageNumber, int pageSize, ArticlesOptions articlesOptions = null)
        {
            var articles = await articleRepository.GetFilteredListPage(pageSize, pageNumber, articlesOptions.SourceIds);

            return(new ArticlePageList
            {
                CurrentPage = pageNumber,
                PageSize = pageSize,
                TotalItems = await articleRepository.Count(articlesOptions.SourceIds),
                Articles = articles.ToList()
            });
        }