コード例 #1
0
        public IActionResult Topic(int id)
        {
            var section = _sectionService.GetByID(id);

            var posts = section.Posts;

            TimeDifference td = new TimeDifference();

            var postListing = posts.Select(post => new PostListingModel
            {
                Id = post.Id,
                Title = post.Title,
                DatePosted = post.Created.ToString(CultureInfo.InvariantCulture),
                Ago = td.PostTimeDifference(post.Created),
                AuthorName = post.User.FirstName + " " + post.User.LastName,
                Section = BuildSectionListing(post)
            }).OrderByDescending(post => post.DatePosted);

            var model = new SectionTopicModel
            {
                Posts = postListing,
                Section = BuildSectionListing(section)
            };

            return View(model);
        }
コード例 #2
0
        private HomeIndexModel BuildHomeIndexModel()
        {
            var            latestPost = _postService.GetLatestPost(10);
            TimeDifference td         = new TimeDifference();

            var posts = latestPost.Select(post => new PostListingModel
            {
                Id         = post.Id,
                Title      = post.Title,
                AuthorName = post.User.FirstName + " " + post.User.LastName,
                DatePosted = td.PostTimeDifference(post.Created),
                Section    = GetSectionListingForPost(post)
            });

            return(new HomeIndexModel
            {
                LatestPosts = posts
            });
        }