Beispiel #1
0
        public async Task <PagedResultDto <BookListDto> > GetPaged(GetBooksInput input)
        {
            var query = _bookRepository.GetAll()

                        //模糊搜索书籍名称
                        .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), a => a.Name.Contains(input.FilterText))
                        //模糊搜索作者
                        .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), a => a.Author.Contains(input.FilterText))
                        //模糊搜索购买链接
                        .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), a => a.PriceUrl.Contains(input.FilterText))
                        //模糊搜索封面链接
                        .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), a => a.ImgUrl.Contains(input.FilterText))
                        //模糊搜索简介
                        .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), a => a.Intro.Contains(input.FilterText))
            ;
            // TODO:根据传入的参数添加过滤条件

            var count = await query.CountAsync();

            var bookList = await query
                           .OrderBy(input.Sorting).AsNoTracking()
                           .PageBy(input)
                           .ToListAsync();

            var bookListDtos = ObjectMapper.Map <List <BookListDto> >(bookList);

            return(new PagedResultDto <BookListDto>(count, bookListDtos));
        }
        public async Task <PagedResultDto <BookListDto> > GetPaged(GetBooksInput input)
        {
            var query = _entityRepository.GetAll();
            // TODO:根据传入的参数添加过滤条件


            var count = await query.CountAsync();

            var entityList = await query
                             .OrderBy(input.Sorting).AsNoTracking()
                             .PageBy(input)
                             .ToListAsync();

            // var entityListDtos = ObjectMapper.Map<List<BookListDto>>(entityList);
            var entityListDtos = entityList.MapTo <List <BookListDto> >();

            return(new PagedResultDto <BookListDto>(count, entityListDtos));
        }
        public async Task <PagedResultDto <BookListDto> > GetPaged(GetBooksInput input)
        {
            var query = _entityRepository
                        .GetAll()
                        .AsNoTracking()
                        // TODO:根据传入的参数添加过滤条件
                        .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), o => o.Name.Contains(input.FilterText));

            var count = await query.CountAsync();

            var entityList = await query
                             .OrderBy(input.Sorting)
                             .PageBy(input)
                             .ToListAsync();

            // var entityListDtos = ObjectMapper.Map<List<BookListDto>>(entityList);
            var entityListDtos = entityList.MapTo <List <BookListDto> >();


            //Host显示租户信息内容
            if (!AbpSession.TenantId.HasValue)
            {
                // 这里的写法需要优化,但是这里我就这么写了
                int i = 0;
                foreach (var item in entityList)
                {
                    if (item.TenantId <= 0)
                    {
                        i++;
                        continue;
                    }


                    var tmpTenant = await TenantManager.GetByIdAsync(item.TenantId);

                    var tmpDto = entityListDtos[i++];
                    tmpDto.TenancyName        = tmpTenant.TenancyName;
                    tmpDto.TenancyDisplayName = tmpTenant.Name;
                }
            }

            return(new PagedResultDto <BookListDto>(count, entityListDtos));
        }
Beispiel #4
0
        /// <summary>
        /// 获取Book的分页列表信息
        ///</summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <BookListDto> > GetPagedBooks(GetBooksInput input)
        {
            var query = _bookRepository.GetAll();
            // TODO:根据传入的参数添加过滤条件

            var bookCount = await query.CountAsync();

            var books = await query
                        .OrderBy(input.Sorting).AsNoTracking()
                        .PageBy(input)
                        .ToListAsync();

            // var bookListDtos = ObjectMapper.Map<List <BookListDto>>(books);
            var bookListDtos = books.MapTo <List <BookListDto> >();

            return(new PagedResultDto <BookListDto>(
                       bookCount,
                       bookListDtos
                       ));
        }
 public virtual Task <PagedResultDto <BookDto> > GetListAsync(GetBooksInput input)
 {
     return(_bookAppService.GetListAsync(input));
 }