Ejemplo n.º 1
0
        public Article GetArticleById(String id)
        {
            Article article = new Article();
            if (id.Length > 6)
            {
                IStoryRepository blogRepo = new BloggerRepository(System.Configuration.ConfigurationManager.AppSettings["blogger_access_token"]);
                article = blogRepo.GetArticleById(id);
            }
            else
            {
                IStoryRepository newsRepo = new NewsRepository();
                article = newsRepo.GetArticleById(id);
            }

            Context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            Context.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type");
            return article;
        }
Ejemplo n.º 2
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;
        }