public virtual PartialViewResult RecentPosts() { var model = new RecentPostsViewModel(); model.BlogPosts = BlogPostHelper.GetRecentPosts(5); return(PartialView(model)); }
public IViewComponentResult Invoke(int numToTake = 7) { RecentPostsViewModel model = new RecentPostsViewModel { Posts = blogRepository.Posts .OrderByDescending(p => p.DateTimePublished) .Take(numToTake) }; return(View(model)); }
public async Task <IViewComponentResult> InvokeAsync(string viewName = "RecentPosts", int numberToShow = 5) { var model = new RecentPostsViewModel(); var settings = await projectService.GetCurrentProjectSettings().ConfigureAwait(false); var list = await postQueries.GetRecentPosts(settings.Id, numberToShow); model.ProjectSettings = settings; model.Posts = list; return(View(viewName, model)); }
public async Task <IViewComponentResult> InvokeAsync(string viewName = "FeaturedPosts", int numberToShow = 5) { var model = new RecentPostsViewModel(_contentProcessor); var settings = await _projectService.GetCurrentProjectSettings().ConfigureAwait(false); var list = await _postQueries.GetFeaturedPosts(settings.Id, numberToShow); model.ProjectSettings = settings; model.Posts = list; model.TimeZoneHelper = _timeZoneHelper; model.TimeZoneId = model.ProjectSettings.TimeZoneId; return(View(viewName, model)); }
public ActionResult RecentPostsWidget(int blogId) { var blog = db.Blogs.Find(blogId); var posts = blog != null?blog.Posts.OrderBy(p => p.PublishDate).Take(5) : new List <Post>(); RecentPostsViewModel vm = new RecentPostsViewModel { BlogUrlName = blog.UrlName, Posts = posts }; return(View("Default/Widgets/_RecentPostsWidget", vm)); }
public ActionResult RecentPosts() { using (ForumRespository db = new ForumRespository()) { var Model = new RecentPostsViewModel(); Model.AddNavigation("Recent Posts"); Forum_User CurrentUser = GetCurrentUser(db); List<int> VisibleCategoryIDList = new List<int>(); var Categories = db.GetAllCategories(); foreach (var Category in Categories) { if (db.CheckCategoryPermissions(Category, CurrentUser, P => P.AllowView)) VisibleCategoryIDList.Add(Category.CategoryID); } var Threads = db.GetSortedThreads().Where(T => VisibleCategoryIDList.Contains(T.CategoryID)); ThreadInfoModelFromThread(db, CurrentUser, Threads.Take(THREADS_PER_PAGE), Model.ThreadInfoList); return View(Model); } }