public ActionResult Item(int forumId, PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); ForumPart forum = _forumService.Get(forumId, VersionOptions.Latest); if (forum == null) { return(HttpNotFound()); } if (!_orchardServices.Authorizer.Authorize(Permissions.ManageForums, forum, T("Not allowed to view forum"))) { return(new HttpUnauthorizedResult()); } var threads = _threadService.Get(forum, pager.GetStartIndex(), pager.PageSize, VersionOptions.Latest).ToArray(); var threadsShapes = threads.Select(bp => _contentManager.BuildDisplay(bp, "SummaryAdmin")).ToArray(); dynamic forumShape = _contentManager.BuildDisplay(forum, "DetailAdmin"); var list = Shape.List(); list.AddRange(threadsShapes); forumShape.Content.Add(Shape.Parts_Forums_Thread_ListAdmin(ContentItems: list), "5"); var totalItemCount = _threadService.Count(forum, VersionOptions.Latest); forumShape.Content.Add(Shape.Pager(pager).TotalItemCount(totalItemCount), "Content:after"); // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. return(View((object)forumShape)); }
private void UpdateForumPartCounters(ThreadPart threadPart) { var commonPart = threadPart.As <CommonPart>(); if (commonPart != null && commonPart.Record.Container != null) { var forumPart = threadPart.ForumPart ?? _forumService.Get(commonPart.Record.Container.Id, VersionOptions.Published); // TODO: Refactor this to do the count in the DB and not make 3 DB calls. forumPart.ThreadCount = _threadService.Count(forumPart, VersionOptions.Published); forumPart.PostCount = _threadService .Get(forumPart, VersionOptions.Published) .Sum(publishedThreadPart => _postService .Count(publishedThreadPart, VersionOptions.Published)); } }
private void UpdateForumPartCounters(ThreadPart threadPart) { var commonPart = threadPart.As <CommonPart>(); if (commonPart != null && commonPart.Record.Container != null) { ForumPart forumPart = threadPart.ForumPart ?? _forumService.Get(commonPart.Record.Container.Id, VersionOptions.Published); forumPart.ThreadCount = _threadService.Count(forumPart, VersionOptions.Published); forumPart.PostCount = _threadService .Get(forumPart, VersionOptions.Published) .Sum(publishedThreadPart => publishedThreadPart.PostCount); } }