Ejemplo n.º 1
0
        public async Task <PaginatedList <PageRecipeCommandResult> > GetPageAsync(PageRecipeCommand command)
        {
            var source = _context.Recipe.AsNoTracking().AsExpandable();
            var outer  = PredicateBuilder.New <RecipeInfo>(true);

            if (!string.IsNullOrEmpty(command.TextToSearch))
            {
                var inner = PredicateBuilder.New <RecipeInfo>();
                inner = inner.Start(RecipeSpecs.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(RecipeSpecs.AsPageRecipeCommandResult)
                        .ToListAsync();

            return(new PaginatedList <PageRecipeCommandResult>(items, count, command.PageNumber, command.PageSize));
        }
Ejemplo n.º 2
0
 public virtual async Task <PaginatedList <PageRecipeCommandResult> > GetPageAsync(PageRecipeCommand command)
 {
     return(await _repository.GetPageAsync(command));
 }