示例#1
0
        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));
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
    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);
    }
示例#5
0
        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;
 }