public async Task <ActionResult> Index(int?page, string searchText) { var totalIngredients = await _ingredientsRepository.GetTotalCountAsync(searchText); Pager pager = new Pager(totalIngredients, page); var ingredients = _ingredientsRepository.GetAll(searchText) .Skip((pager.CurrentPage - 1) * pager.PageSize) .Take(pager.PageSize); var viewModel = new IngredientsIndexViewModel() { Ingredients = ingredients, Pager = pager, SearchText = searchText }; return(View(viewModel)); }