public async Task <Response <IReadOnlyList <TagInfo> > > GetHotTagsAsync(int top) { try { if (_tagRepository.Any()) { var spec = new TagSpec(top); var hotTags = await _tagRepository.SelectAsync(spec, t => new TagInfo { TagCount = t.PostTag.Count, TagName = t.DisplayName, NormalizedTagName = t.NormalizedName }); return(new SuccessResponse <IReadOnlyList <TagInfo> >(hotTags)); } return(new SuccessResponse <IReadOnlyList <TagInfo> >(new List <TagInfo>())); } catch (Exception e) { Logger.LogError(e, $"Error {nameof(GetHotTagsAsync)}"); return(new FailedResponse <IReadOnlyList <TagInfo> >((int)ResponseFailureCode.GeneralException)); } }
public async Task <IReadOnlyList <DegreeTag> > GetHotTagsAsync(int top) { if (!_tagRepository.Any()) { return(new List <DegreeTag>()); } var spec = new TagSpec(top); var tags = await _tagRepository.SelectAsync(spec, t => new DegreeTag { Degree = t.PostTag.Count, DisplayName = t.DisplayName, NormalizedName = t.NormalizedName }); return(tags); }
public async Task <IReadOnlyList <KeyValuePair <Tag, int> > > GetHotTagsAsync(int top) { if (!_tagRepo.Any()) { return(new List <KeyValuePair <Tag, int> >()); } var spec = new TagSpec(top); var tags = await _tagRepo.SelectAsync(spec, t => new KeyValuePair <Tag, int>(new() { Id = t.Id, DisplayName = t.DisplayName, NormalizedName = t.NormalizedName }, t.Posts.Count)); return(tags); }
public async Task <IReadOnlyList <KeyValuePair <Tag, int> > > Handle(GetHotTagsQuery request, CancellationToken cancellationToken) { if (!_tagRepo.Any()) { return(new List <KeyValuePair <Tag, int> >()); } var spec = new TagSpec(request.Top); var tags = await _tagRepo.SelectAsync(spec, t => new KeyValuePair <Tag, int>(new() { Id = t.Id, DisplayName = t.DisplayName, NormalizedName = t.NormalizedName }, t.Posts.Count)); return(tags); }
public Task <Response <IReadOnlyList <TagCountInfo> > > GetHotTagsAsync(int top) { return(TryExecuteAsync <IReadOnlyList <TagCountInfo> >(async() => { if (_tagRepository.Any()) { var spec = new TagSpec(top); var hotTags = await _tagRepository.SelectAsync(spec, t => new TagCountInfo { TagCount = t.PostTag.Count, TagName = t.DisplayName, NormalizedTagName = t.NormalizedName }); return new SuccessResponse <IReadOnlyList <TagCountInfo> >(hotTags); } return new SuccessResponse <IReadOnlyList <TagCountInfo> >(new List <TagCountInfo>()); }, keyParameter: top)); }
public TellMessage(ProcessId processId, object message, ProcessId sender, TagSpec tag) { ProcessId = processId; Message = message; Sender = sender; this.tag = tag; }