예제 #1
0
        public virtual PartialViewResult RecentPosts()
        {
            var model = new RecentPostsViewModel();

            model.BlogPosts = BlogPostHelper.GetRecentPosts(5);
            return(PartialView(model));
        }
예제 #2
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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);
            }
        }