public ActionResult Index() { var model = new SidebarViewModel(); model.RecentPosts = this.Cache.Get( "RecentBlogPosts", () => this.blogPosts.All() .OrderByDescending(x => x.CreatedOn) .Project() .To<RecentBlogPostViewModel>() .Take(5) .ToList(), 600); model.Tags = this.tags.All().Project().To<TagViewModel>().OrderByDescending(x => x.PostsCount).ToList(); model.RecentVideos = this.Cache.Get( "RecentVideos", () => { if (string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["YouTubeApiKey"])) { return new List<VideoListItemViewModel>(); } return new LatestVideosProvider(ConfigurationManager.AppSettings["YouTubeApiKey"]).GetLatestVideos( 5, "UULC-vbm7OWvpbqzXaoAMGGw").Project().To<VideoListItemViewModel>().ToList(); }, 7200); return this.PartialView("_SidebarPartial", model); }
public ActionResult Index() { var model = new SidebarViewModel { RecentPosts = this.blogPosts.All() .OrderByDescending(x => x.CreatedOn) .Project() .To<RecentBlogPostViewModel>() .Take(10), Tags = this.tags.All() .Project() .To<TagViewModel>() .OrderByDescending(x => x.PostsCount) }; return this.PartialView("_SidebarPartial", model); }