public async Task <IActionResult> PostAsync( [FromBody] VehicleFilter filter) { var adapter = new GridQueryAdapter(filter); ICollection <Vehicle> vehicles = null; // this call both executes a count to get total items and // updates the paging information await _repo.QueryAsync( async query => vehicles = await adapter.FetchAsync(query)); return(new OkObjectResult(new { PageInfo = filter.PageHelper, Vehicles = vehicles })); }
public async Task <IActionResult> PostAsync( [FromBody] ContactFilter filter) { // is the database there? // NOTE: this is intended to make the sample app easy to run, // and will create and seed the database. This is NOT code to // put into production. Instead, look to migrations or another // method. var seed = _serviceProvider.GetService <SeedContacts>(); await seed.CheckAndSeedDatabaseAsync(User); var adapter = new GridQueryAdapter(filter); ICollection <Contact> contacts = null; // this call both executes a count to get total items and // updates the paging information await _repo.QueryAsync( async query => contacts = await adapter.FetchAsync(query)); return(new OkObjectResult(new { PageInfo = filter.PageHelper, Contacts = contacts })); }