public async Task <PagedView <View.City> > Get(CityGetBinding binding) { using (var context = GetMainContext()) { var query = context.Cities.Include(x => x.Country) .WhereIf(!string.IsNullOrEmpty(binding.Search), city => city.Name.ToLower().Contains(binding.Search.ToLower())) .WhereIf(!string.IsNullOrEmpty(binding.CountryId), city => city.Country.ValueId == binding.CountryId) .OrderBy(x => x.Name) .Select(x => new View.City(x)); return(await query.ToPagedViewAsync(binding)); } }
public async Task <IActionResult> Get([FromQuery] CityGetBinding binding) => Ok(await _cityHandler.Get(binding));