public async Task <IActionResult> GetTopicProfile(string topicId) { var id = XUtils.ParseId(topicId); var topic = await Context.Topics.FirstOrDefaultAsync(p => p.Id == id); var qtopic = QTopic.NormalView(topic); return(Ok(qtopic)); }
public async Task <IActionResult> QueryTopics(Guid relatedWork, bool?isGroup) { var query = from p in Context.Topics.Where(p => p.RelatedWork == relatedWork) select p; query = isGroup == null ? query : query.Where(p => p.IsGroup == isGroup); var topics = await query.OrderBy(p => p.CreatedAt).Take(20).ToListAsync(); var qtopics = topics.Select(p => QTopic.NormalView(p)).ToList(); return(Ok(qtopics)); }
public async Task <IActionResult> HotestGroups() { var query = from p in Context.Topics.Where(p => p.IsGroup == true) select new { topic = p, discussionCount = Context.Discussions.Count(o => o.TopicId == p.Id) } into k orderby k.discussionCount descending select k; var topics = await query.Take(20).ToListAsync(); var qtopics = topics.Select(p => QTopic.NormalView(p.topic)); return(Ok(qtopics)); }
public async Task <IActionResult> SearchTopics(string word, bool isGroup, int page) { word ??= ""; page = Math.Max(0, page); const int pageSize = 20; var query = from p in Context.Topics where p.IsGroup == isGroup && p.Tsv.Matches(EF.Functions.WebSearchToTsQuery("testzhcfg", word)) orderby p.Tsv.RankCoverDensity(EF.Functions.WebSearchToTsQuery("testzhcfg", word)) descending select p; var data = await query.Skip(page *pageSize).Take(pageSize).ToListAsync(); var qtopics = data.Select(p => QTopic.NormalView(p)); return(Ok(qtopics)); }