public async Task <IEnumerable <CityDto> > Get([FromQuery] CityRequestDto query) { var country = Countries.Germany; Func <Task <IEnumerable <CityDto> > > cityInfoCache = () => _cityInfoService.GetCities(country); var citiesOfCountry = await _cache.GetOrAddAsync <IEnumerable <CityDto> >($"citiesOf{country}", cityInfoCache, DateTimeOffset.Now.AddHours(24)); return(citiesOfCountry.Where(x => x.Name.ToLower().StartsWith(query.Name.ToLower())).ToList()); }
public IActionResult GetCities() { var cities = _cityInfoService.GetCities(); if (!cities.Any()) { return(NoContent()); } var citiesMapped = cities.Select(MapCity); return(Ok(citiesMapped)); }