public async Task <IActionResult> Index(SelectionOptions inStock = SelectionOptions.Active , SelectionOptions isFeed = SelectionOptions.All , int page = 1 , int perPage = Constants.ItemsPerPage) { int items = await _repository.GetInventoryItemsCountAsync(inStock, isFeed); if (perPage < 2) { perPage = Constants.ItemsPerPage; } int pages = (items - 1 / perPage); if (page < 1) { page = 1; } if (page > pages) { page = pages; } InventoryItemsIndexViewModel model = new InventoryItemsIndexViewModel() { Page = page, Pages = pages, PerPage = perPage, InStock = inStock, IsFeed = isFeed, InventoryItems = await _repository.GetInventoryItemsAsync(inStock, isFeed, page, perPage) }; ViewBag.Title = _stringLocalizer["Inventory Items"].ToString(); return(View(model)); }