コード例 #1
0
        public List <ArticleResponseModel> GetStoriesBySection(SectionType sectionType, Func <Result, bool> condition)
        {
            sectionType.ThrowIfDefault(nameof(sectionType));
            condition.ThrowIfNull(nameof(condition));

            return(GetStoriesBySectionAndFilter(sectionType, condition));
        }
コード例 #2
0
        public List <ArticleGroupByDateResponseModel> GetArticleGroupBySection(SectionType sectionType)
        {
            sectionType.ThrowIfDefault(nameof(sectionType));

            var articlesResult = _webProvider.GetArticlesNyt(sectionType);

            if (articlesResult == null || articlesResult.results?.Count == 0)
            {
                throw new System.Exception("Nothing has been returned.");
            }

            return(_mapperFactory.GetMapper <ArticlesNYT, ArticleGroupByDateResponseModel>().Map(articlesResult));
        }
コード例 #3
0
        private List <ArticleResponseModel> GetStoriesBySectionAndFilter(SectionType sectionType, Func <Result, bool> condition = null)
        {
            sectionType.ThrowIfDefault(nameof(sectionType));

            var articlesResult = _webProvider.GetArticlesNyt(sectionType);

            if (articlesResult == null || articlesResult.results?.Count == 0)
            {
                throw new System.Exception("Nothing has been returned.");
            }

            if (condition != null)
            {
                articlesResult.results = articlesResult.results.Where(condition).ToList();
            }

            return(_mapperFactory.GetMapper <ArticlesNYT, ArticleResponseModel>().Map(articlesResult));
        }
コード例 #4
0
        public List <ArticleResponseModel> GetStoriesBySection(SectionType sectionType)
        {
            sectionType.ThrowIfDefault(nameof(sectionType));

            return(GetStoriesBySectionAndFilter(sectionType));
        }