Exemple #1
0
        public IEnumerable <Article> RetrieveAllArticles()
        {
            var feeds    = _rssFeedRepository.Feeds();
            var articles = Enumerable.Empty <Article>();

            using (var wclient = new WebClient())
            {
                foreach (var feed in feeds)
                {
                    var rssData = wclient.DownloadString(feed.Url);
                    var xml     = XDocument.Parse(rssData);

                    // TODO: Need the rest of the fields
                    articles = articles.Concat(xml.Descendants("item").Select(x => new Article
                    {
                        Title       = (string)x.Element("title"),
                        Description = (string)x.Element("description"),
                        Source      = feed.Title
                    }));
                }
            }

            return(articles.ToList());
        }