Exemple #1
0
        public async Task <PaginatedList <PageIngredientCommandResult> > GetPageAsync(PageIngredientCommand command)
        {
            var source = _context.Ingredient.AsNoTracking().AsExpandable();
            var outer  = PredicateBuilder.New <IngredientInfo>(true);

            if (!string.IsNullOrEmpty(command.TextToSearch))
            {
                var inner = PredicateBuilder.New <IngredientInfo>();
                inner = inner.Start(IngredientSpecs.TextToSearch(command.TextToSearch));
                outer = outer.And(inner);
            }

            var count = await source.Where(outer).CountAsync();

            var items = await source.Where(outer)
                        .Skip(command.SkipNumber)
                        .Take(command.PageSize)
                        .Select(IngredientSpecs.AsPageIngredientCommandResult)
                        .ToListAsync();

            return(new PaginatedList <PageIngredientCommandResult>(items, count, command.PageNumber, command.PageSize));
        }
 public virtual async Task <PaginatedList <PageIngredientCommandResult> > GetPageAsync(PageIngredientCommand command)
 {
     return(await _repository.GetPageAsync(command));
 }