Fixed Tag page error

  • Last Post 14 September 2017
siaonong posted this 14 September 2017

When you choose a tag name on the right side panel of home page, it will show the related topics of that tag by pages. But somewhat it will fail to show the content except the 1st page, as shown in the attached picture below.

It's because the linq statement with wrong sequence in GetPagedTopicsByTag() of TopicService. So I fixed it as the statement below:

List<Topic> results = _context.Topic
 .Include(x => x.Category)
 .Include(x => x.LastPost.User)
 .Include(x => x.User)
 .Include(x => x.Poll)
 .Include(x => x.Tags)
 .Where(x => x.Pending != true && allowedCatIds.Contains(x.Category.Id))
 .OrderByDescending(x => x.IsSticky)
 .ThenByDescending(x => x.LastPost.DateCreated)
 .Where(e => e.Tags.Any(t => t.Slug.Equals(tag)))
 .Skip(( pageIndex - 1 ) * pageSize)
 .Take(pageSize)   //Skip statement was after Take statement which made the results = 0 before

siaonong posted this 14 September 2017

Github issue #142

  • Liked by
  • YodasMyDad