public ActionResult Thread(string key, int? page) { var currentThread = string.IsNullOrEmpty(key) ? _threadDriver.RootThread : _threadDriver.GetThreadByKey(key); if (currentThread == null) { return HttpNotFound(); } var tagCategoryMaps = _threadDriver.GetTagCategories(currentThread.Id); List<TagListClient> tagLists = new List<TagListClient>(); foreach (var map in tagCategoryMaps) { var tagList = _tagDriver.GetTagsByCategory(map.TagCategory.Name, map.OnlyShowHotTag, map.IncludeAll, map.IncludeOther); tagLists.Add(tagList); } ViewBag.TagLists = tagLists; PageTopicFilterClient topicFilter = new PageTopicFilterClient(); topicFilter.PageNumber = GetPageNumber(page);; topicFilter.ThreadKey = currentThread.Key; topicFilter.Sort = " CreateTime DESC"; PageListClient<TopicClient> pageList = _topicDriver.PagingClientTopics(DefaultSetting.TopicsPerPage, topicFilter); PageTopicClient pageTopic = new PageTopicClient() { Page = pageList, Filter = topicFilter }; ViewBag.CurrentThread = currentThread; pageTopic.Page.GenerateUniqueId(); return View("Thread", pageTopic); }
//get topics on paging public PageListClient <TopicClient> PagingClientTopics(int pageSize, PageTopicFilterClient filter) { Expression <Func <ContentTopic, bool> > predicate = PredicateBuilder.True <ContentTopic>(); // null; // = x => x.IsVisible == false; predicate = predicate.And(x => !x.IsHidden); //Ignore it, if there is only one thread in the system if (_threadWork.TotalThreadCount > 1) { ContentThread thread = _threadWork.GetThread(filter.ThreadKey); Expression <Func <ContentTopic, bool> > threadPredicate = PredicateBuilder.False <ContentTopic>(); threadPredicate = threadPredicate.Or(x => x.ThreadId == thread.Id); predicate = predicate.And(threadPredicate.Expand()); } foreach (var tagOption in filter.TagOptions) { if (string.IsNullOrEmpty(tagOption.IdStrs) || tagOption.IdStrs.Contains(WebConstants.Tag_Specifier_All)) { continue; } List <Guid> tagIds = tagOption.ToTagIds(); if (tagIds.Count > 0) { Expression <Func <ContentTopic, bool> > singleTagPredicate = PredicateBuilder.False <ContentTopic>(); foreach (var tagId in tagIds) { singleTagPredicate = singleTagPredicate.Or(x => x.Tags.Select(t => t.Id).Contains(tagId)); } if (singleTagPredicate != null) { predicate = predicate.And(singleTagPredicate.Expand()); //call expand() to fix not bound error } } } var pageTopic = _topicWork.Paging(filter.PageNumber, pageSize, filter.Sort, predicate, new string[] { "Tags" }); PageListClient <TopicClient> page = new PageListClient <TopicClient>(pageTopic, pageTopic.Count); foreach (var topic in pageTopic) { page.Add(ToClient(topic, excludeProperties: new string[] { "Tags", "FirstComment", "Comments", "UploadPermission" })); } return(page); }
public ActionResult Thread(string key, int?page) { var currentThread = string.IsNullOrEmpty(key) ? _threadDriver.RootThread : _threadDriver.GetThreadByKey(key); if (currentThread == null) { return(HttpNotFound()); } var tagCategoryMaps = _threadDriver.GetTagCategories(currentThread.Id); List <TagListClient> tagLists = new List <TagListClient>(); foreach (var map in tagCategoryMaps) { var tagList = _tagDriver.GetTagsByCategory(map.TagCategory.Name, map.OnlyShowHotTag, map.IncludeAll, map.IncludeOther); tagLists.Add(tagList); } ViewBag.TagLists = tagLists; PageTopicFilterClient topicFilter = new PageTopicFilterClient(); topicFilter.PageNumber = GetPageNumber(page);; topicFilter.ThreadKey = currentThread.Key; topicFilter.Sort = " CreateTime DESC"; PageListClient <TopicClient> pageList = _topicDriver.PagingClientTopics(DefaultSetting.TopicsPerPage, topicFilter); PageTopicClient pageTopic = new PageTopicClient() { Page = pageList, Filter = topicFilter }; ViewBag.CurrentThread = currentThread; pageTopic.Page.GenerateUniqueId(); return(View("Thread", pageTopic)); }
public ClientModel TopicsByFilter([FromBody] PageTopicFilterClient fitler) { var pageTopic = _topicDriver.PagingClientTopics(DefaultSetting.TopicsPerPage, fitler); return(pageTopic); }