Example #1
0
        public async Task <List <CBookEntity> > SearchAsync(string searchPath, string searchAuthor, string searchKeyword, IEnumerable <SortableItem> sortables)
        {
            var query = this.dbContext.Set <CBookEntity>()
                        .Where <CBookEntity>(book => StringUtils.IsBlank(searchPath) || book.Path.Contains(searchPath))
                        .Where <CBookEntity>(book => StringUtils.IsBlank(searchAuthor) || book.Author.Contains(searchAuthor))
                        .Where <CBookEntity>(book => StringUtils.IsBlank(searchKeyword) || book.Title.Contains(searchKeyword) || book.Name.Contains(searchKeyword));

            query = OrderUtils.Sort <CBookEntity>(query, sortables);

            return(await query.ToListAsync <CBookEntity>());
        }
Example #2
0
        public async Task <List <AVideoEntity> > SearchAsync(string searchPath, string searchProducer, string searchKeyword, IEnumerable <SortableItem> sortables)
        {
            //var Id = new SqlParameter("author", "%" + searchAuthor + "%");

            var query = this.dbContext.Set <AVideoEntity>()
                        .Where <AVideoEntity>(video => StringUtils.IsBlank(searchPath) || video.Path.Contains(searchPath))
                        .Where <AVideoEntity>(video => StringUtils.IsBlank(searchProducer) || video.Producer.Contains(searchProducer))
                        .Where <AVideoEntity>(video => StringUtils.IsBlank(searchKeyword) || video.Title.Contains(searchKeyword) || video.Name.Contains(searchKeyword));

            query = OrderUtils.Sort <AVideoEntity>(query, sortables);

            return(await query.ToListAsync <AVideoEntity>());
        }
Example #3
0
        public async Task <PagedList <CBookEntity> > SearchPagedAsync(
            string searchPath, string searchAuthor, string searchKeyword, IEnumerable <SortableItem> sortables,
            int pageSize, int pageIndex)
        {
            var query = this.dbContext.Set <CBookEntity>()
                        .Where <CBookEntity>(book => StringUtils.IsBlank(searchPath) || book.Path.Contains(searchPath))
                        .Where <CBookEntity>(book => StringUtils.IsBlank(searchAuthor) || book.Author.Contains(searchAuthor))
                        .Where <CBookEntity>(book => StringUtils.IsBlank(searchKeyword) || book.Title.Contains(searchKeyword) || book.Name.Contains(searchKeyword));

            query = OrderUtils.Sort <CBookEntity>(query, sortables);

            int totalCount = query.Count();

            PagedList <CBookEntity> result = new PagedList <CBookEntity>(pageSize, pageIndex, totalCount);

            result.Data = await query
                          .Skip(result.Skip())
                          .Take(result.Take())
                          .ToListAsync <CBookEntity>();

            return(result);
        }