Exemple #1
0
        public IActionResult Details(int id, string searchQuery)
        {
            var posts = new List <Post>();
            var forum = _forum.GetById(id);

            posts = _post.GetFilteredPosts(forum, searchQuery).ToList();

            var postListings = posts.Select(p => new PostListingModel
            {
                Id           = p.Id,
                AuthorId     = p.User.Id.ToString(),
                AuthorRating = p.User.Rating,
                Title        = p.Title,
                DatePosted   = p.Created.ToString(),
                RepliesCount = p.Replies.Count(),
                AuthorName   = p.User.UserName,
                Forum        = BuildForumListing(p)
            });

            var model = new ForumDetailsModel
            {
                Posts       = postListings,
                Forum       = BuildForumListing(forum),
                SearchQuery = searchQuery
            };



            return(View(model));
        }
Exemple #2
0
        public IActionResult Details(int id)
        {
            var forum = _forum.GetById(id);

            var posts = forum.Posts;

            var postVM = posts.Select(post => new PostViewModel
            {
                Id           = post.Id,
                AuthorId     = post.User.Id,
                AuthorRating = post.User.Rating,
                Title        = post.Title,
                DatePosted   = post.Created.ToString(),
                RepliesCount = post.Replies.Count(),
                Forum        = BuildForumViewModel(post)
            });

            var model = new ForumDetailsModel
            {
                Posts = postVM,
                Forum = BuildForumViewModel(forum)
            };

            return(View(model));
        }
Exemple #3
0
        public ActionResult ViewForum(long?id, int?page)
        {
            int pageSize = 25;

            if (!id.HasValue)
            {
                return(View("NotAvailable"));
            }

            Forum f = this.Forums.GetForum(id.Value);

            if (f == null)
            {
                return(View("NotFound"));
            }

            ForumAccess a = this.Security.GetUserForumAccess(CurrentUser, f);

            if (!a.CanView)
            {
                return(View("NotAuthorized"));
            }

            var threadSource = this.Forums.GetForumViewableThreads(f.ForumID);

            var threadCount = threadSource.Count();
            var threads     = GetThreadInformation(threadSource, CurrentUser);
            int pages       = Pager.PageCount(threadCount, pageSize);

            page = Pager.ClampPage(page, pages);

            var threadsList = new ThreadList
            {
                Threads = threads.OrderByDescending(t => t.LastPostDate).OrderByDescending(t => t.Thread.Level).Skip((page.Value - 1) * pageSize).Take(pageSize).ToList()
            };

            var fd = new ForumDetailsModel
            {
                Forum      = f,
                UserAccess = a,
                PageInfo   = new PaginationInformation
                {
                    Pager          = this.Skins.GetDefaultForumPager(),
                    ControllerName = "Forums",
                    ActionName     = "ViewForum",
                    PageAttribute  = "page",
                    RouteValues    = new System.Web.Routing.RouteValueDictionary(new { id = id }),
                    ItemsPerPage   = pageSize,
                    Items          = threadCount,
                    CurrentPage    = page
                },
                Threads = threadsList
            };

            return(View("ViewForum", fd));
        }