Example #1
0
 public ActionResult GetFeaturedRecentPosts()
 {
     using (var repo = new BlogPostRepo())
     {
         var recents = repo.ListRecentBlogPosts(3).ToList();
         return PartialView("_RecentPosts", recents);
     }
 }        
Example #2
0
 public ActionResult ListRecentPosts(bool showAll = false)
 {
     using (var repo = new BlogPostRepo())
     {
         int numPosts = showAll ? int.MaxValue : Helpers.Config.NumPostsFrontPage;
         var recents = repo.ListRecentBlogPosts(numPosts).ToList();
         return View("Front", new Front_vm { RecentBlogPosts = recents });
     }
 }
Example #3
0
        public RssActionResult GenerateRSS()
        {
            using (var repo = new BlogPostRepo())
            {
                var items = repo.ListRecentBlogPosts(int.MaxValue).Select(x =>
                    new SyndicationItem(
                    title: x.Title,
                    content: x.Intro,
                    lastUpdatedTime: x.PublishedOn.Value,
                    id: GenerateBlogLink(x.UrlSlug),
                    itemAlternateLink: new Uri(GenerateBlogLink(x.UrlSlug)))
                    );

                SyndicationFeed feed = new SyndicationFeed
                {
                    Title = new TextSyndicationContent("{0}'s Blog".FormatWith(Thyme.Web.Helpers.Config.MyName)),
                    Description = new TextSyndicationContent("Blog feed for {0}".FormatWith(Request.Url.Host)),
                    Language = "en-us",
                    LastUpdatedTime = items.OrderByDescending(x => x.PublishDate).First().PublishDate.ToUniversalTime(),
                    Items = items,

                };
                feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(GenerateBlogLink())));
                return new RssActionResult() { Feed = feed };
            }
        }