public async Task <IActionResult> OnGetLoadTagAsync() { var queryInput = new QueryTagInputDto(); queryInput.FetchFromOther(Query.ToDto()); var result = (await _tagService.GetTagByPageAsync(queryInput)).ToBootStrapQueryResultModel(); //var result = (await _categoryService.GetCategoryByPageAsync(queryInput)).ToBootStrapQueryResultModel(); return(new JsonResult(result)); }
public async Task GetTagsByPage_TestAsync() { var query = new QueryTagInputDto() { MaxResultCount = 5, SkipCount = 0, }; var result = await _tagService.GetTagByPageAsync(query); result.TotalCount.ShouldBeGreaterThan(5); foreach (var item in result.Items) { item.ArticleCount.ShouldBeGreaterThan(0); } }
public async Task <PagedResultDto <TagDto> > GetTagByPageAsync(QueryTagInputDto queryInput) { var query = _tagRep.GetAll(); var resultList = await query .Include(o => o.ArticleTags) .Skip(queryInput.SkipCount) .Take(queryInput.MaxResultCount) .Select(c => new TagDto() { Id = c.Id, Name = c.Name, ArticleCount = c.ArticleTags.Count }) .ToListAsync(); var total = await query.CountAsync(); return(new PagedResultDto <TagDto>(total, resultList)); }