public async Task <ActionResult> GetAllDrinks(string sortOrder, string currentFilter, string searchString, int?page) { ViewData["CurrentSort"] = sortOrder; ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewData["PriceSortParm"] = sortOrder == "Price" ? "price_desc" : "Price"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; var drinks = from s in _db.Drinks select s; var result = PagedService <DrinksInfoDto> .GetDrinks(sortOrder, drinks); int pageSize = 3; return(View(await PagedService <Drink> .CreateAsync(result.AsNoTracking(), page ?? 1, pageSize))); }
protected async Task <IActionResult> GetAsync <TPagingFilter>(TPagingFilter queryExpression) where TPagingFilter : AbstractPagingFilter <TEntity> { Logger.LogInformation($"List of {CurrentEntityLogicalName} requested"); var response = await PagedService.GetPagedAsync(queryExpression); return(Ok(response)); }
public async Task <ActionResult <PagedService <PokemonSerialize> > > GetAll( string name = "", int page = 1, int quantity = 9 ) { var pokemons = await _pokemonRepository.GetPokemonsByNameAsync(name); foreach (var poke in pokemons) { poke.Image = RetrieveRawUrlImage(poke.Number); } var pokes = pokemons .Select(poke => new PokemonSerialize(poke)); var pagedPokemons = new PagedService <PokemonSerialize>(pokes, page, quantity); return(Ok(pagedPokemons)); }