public async Task <PaginatedList <PageRecipeIngredientCommandResult> > GetPageAsync(PageRecipeIngredientCommand command)
        {
            var source = _context.RecipeIngredient.AsNoTracking().AsExpandable();
            var outer  = PredicateBuilder.New <RecipeIngredientInfo>(true);

            if (command.IngredientId.Any())
            {
                outer = outer.Start(x => command.IngredientId.Contains(x.IngredientId.Value));
            }

            if (command.AmountTypeId.Any())
            {
                outer = outer.Start(x => command.AmountTypeId.Contains(x.AmountTypeId.Value));
            }

            if (!string.IsNullOrEmpty(command.TextToSearch))
            {
                var inner = PredicateBuilder.New <RecipeIngredientInfo>();
                inner = inner.Start(RecipeIngredientSpecs.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)
                        .Include(x => x.Ingredient)
                        .Include(x => x.AmountType)
                        .Select(RecipeIngredientSpecs.AsPageRecipeIngredientCommandResult)
                        .ToListAsync();

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