public Feed(Posts posts, HttpContextWrapper contextWrapper) { _contextWrapper = contextWrapper; SetupFeed(); AddPostsToFeed(posts); }
public ActionResult Feed(string type) { var feedType = FeedType.unknown; if (!Enum.TryParse(type.ToLower(), out feedType)) { HttpContextWrapper.SendHttpStatusResponse(404); } var posts = new Posts(HttpContextWrapper); var feed = new Feed(posts, HttpContextWrapper); return feed.GetFeedXml(feedType); }
private void AddPostsToFeed(Posts posts) { var feedItems = new List<SyndicationItem>(); foreach (var post in posts.List) { var item = new SyndicationItem { Title = SyndicationContent.CreatePlaintextContent(post.Title), Summary = SyndicationContent.CreatePlaintextContent(post.ShortDescription), PublishDate = post.PublishDate, LastUpdatedTime = post.PublishDate }; item.Links.Add(SyndicationLink.CreateSelfLink(_contextWrapper.GetAbsoluteUrl("~/blog/" + post.Title))); item.Authors.Add(new SyndicationPerson { Name = post.Author }); feedItems.Add(item); } _feed.Items = feedItems; }