Esempio n. 1
0
 public async Task <ActionResult <GetInsightsJsonDto> > GetInsights(PostInsightsType insights)
 {
     return(Ok(await Mediator.Send(new GetInsightsQuery()
     {
         InsightsType = insights
     })));
 }
Esempio n. 2
0
        public Task <IReadOnlyList <PostSegment> > GetInsightsAsync(PostInsightsType insightsType)
        {
            var spec = new PostInsightsSpec(insightsType, 10);

            return(_postRepo.SelectAsync(spec, p => new PostSegment
            {
                Id = p.Id,
                Title = p.Title,
                Slug = p.Slug,
                PubDateUtc = p.PubDateUtc,
                IsPublished = p.IsPublished,
                IsDeleted = p.IsDeleted,
                CreateOnUtc = p.CreateOnUtc,
                Hits = p.PostExtension.Hits
            }));
        }
Esempio n. 3
0
        public Task <IReadOnlyList <PostMetaData> > GetMPostInsightsMetaListAsync(PostInsightsType insightsType)
        {
            var spec = new PostInsightsSpec(insightsType, 10);

            return(_postRepository.SelectAsync(spec, p => new PostMetaData
            {
                Id = p.Id,
                Title = p.Title,
                Slug = p.Slug,
                PubDateUtc = p.PostPublish.PubDateUtc,
                IsPublished = p.PostPublish.IsPublished,
                IsDeleted = p.PostPublish.IsDeleted,
                Revision = p.PostPublish.Revision,
                CreateOnUtc = p.CreateOnUtc,
                Hits = p.PostExtension.Hits
            }));
        }
Esempio n. 4
0
        public PostInsightsSpec(PostInsightsType insightsType, int top) : base(p => !p.PostPublish.IsDeleted && p.PostPublish.IsPublished)
        {
            switch (insightsType)
            {
            case PostInsightsType.TopRead:
                ApplyOrderByDescending(p => p.PostExtension.Hits);
                break;

            case PostInsightsType.TopCommented:
                ApplyOrderByDescending(p => p.Comment.Count);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(insightsType), insightsType, null);
            }

            UseCriteria(p => p.PostPublish.PubDateUtc >= DateTime.UtcNow.AddYears(-1));

            ApplyPaging(0, top);
        }
Esempio n. 5
0
 public ListInsightsQuery(PostInsightsType postInsightsType)
 {
     PostInsightsType = postInsightsType;
 }