public async Task <ActionResult <GetInsightsJsonDto> > GetInsights(PostInsightsType insights) { return(Ok(await Mediator.Send(new GetInsightsQuery() { InsightsType = insights }))); }
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 })); }
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 })); }
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); }
public ListInsightsQuery(PostInsightsType postInsightsType) { PostInsightsType = postInsightsType; }