Esempio n. 1
0
        public List <Article> GetAllArticles(Boolean onlyActive, Int32 numberOfArticles)
        {
            if (numberOfArticles == 0)
            {
                numberOfArticles = _maxArticles;
            }

            List <Article> allArticles = new List <Article>();
            List <Article> articles    = new List <Article>();
            List <Article> blogPosts   = new List <Article>();

            IStoryRepository newsRepo = new NewsRepository();
            IStoryRepository blogRepo = new BloggerRepository(System.Configuration.ConfigurationManager.AppSettings["blogger_access_token"]);

            articles  = newsRepo.GetArticles(onlyActive, numberOfArticles);
            blogPosts = blogRepo.GetArticles(onlyActive, numberOfArticles);

            allArticles = articles.Concat(blogPosts).OrderByDescending(a => a.DatePublished).Take(numberOfArticles).ToList();

            Context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            Context.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type");
            return(allArticles);
        }