예제 #1
0
        public IActionResult Topic(int id)
        {
            var forum = _forumService.GetByID(id);
            //var posts = _postService.GetPostsByForum(id); REFACTORING
            var posts = forum.Posts;

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

            var model = new ForumTopicModel
            {
                Posts = postListings,
                Forum = BuildForumListing(forum)
            };

            return(View(model));
        }
예제 #2
0
        public IActionResult Topic(int id)
        {
            var forum = _forumService.GetByID(id);
            var posts = _postService.GetPostsByForum(id);

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

            var model = new ForumTopicModel
            {
                Posts = postListings,
                Forum = BuildForumListing(forum)
            };

            return(View(model));
        }