Esempio n. 1
0
 public async Task<CategoryPageOutput> GetTagByPage(CategoryPageInput input)
 {
     return await GetByPage(input, TaxonomyEnum.PostTag);
 }
Esempio n. 2
0
        public async Task<CategoryPageOutput> GetByPage(CategoryPageInput input, TaxonomyEnum taxonomy)
        {
            //跳过条数
            var skipCount = (input.PageIndex - 1) * input.PageSize;
            //获取条数
            var maxResultCount = input.PageSize;

            //获取总条数
            var totalCount = await _categoryRepository.CountAsync(w => w.Taxonomy == taxonomy);
            //获取集合
            var categoryList =
                await _categoryRepository.GetEnumerableByPage(skipCount, maxResultCount, taxonomy, o => o.CreationTime);
            var result = new CategoryPageOutput
            {
                TotalCount = totalCount,
                Items = Mapper.Map<IReadOnlyList<CategoryDto>>(categoryList),
                PageIndex = input.PageIndex
            };
            return result;
        }
Esempio n. 3
0
        public async void Should_GetByPage()
        {
            var input1 = new CategoryPageInput()
            {
                PageIndex = 1,
                PageSize = 5
            };

            var input2 = new CategoryPageInput()
            {
                PageIndex = 0,
                PageSize = 0
            };

            var input3 = new CategoryPageInput()
            {
                PageIndex = 2,
                PageSize = 5
            };

            var output1 = await _categoryService.GetCategoryByPage(input1);
            var output2 = await _categoryService.GetCategoryByPage(input2);
            var output3 = await _categoryService.GetCategoryByPage(input3);

            output1.TotalCount.ShouldBe(1);
            output1.TotalCount.ShouldBe(output2.TotalCount);
            output1.Items.Count.ShouldBe(output2.Items.Count);
            output1.Items.Count().ShouldBe(1);
            output3.TotalCount.ShouldBe(1);
            output3.Items.Count.ShouldBe(0);
        }