Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public IActionResult Create(int id)
        {
            //id is SectionId
            var section = _sectionService.GetByID(id);

            var model = new NewPostModel
            {
                SectionName = section.Title,
                SectionId   = section.Id,
                AuthorName  = User.Identity.Name
            };

            return(View(model));
        }