public async Task <IActionResult> GetCitiesForCountry(int countryId) { if (!await _countryRepository.CountryExistAsync(countryId)) { return(NotFound()); } var citiesForCountry = await _cityRepository.GetCitiesForCountryAsync(countryId); var citiesResources = _mapper.Map <IEnumerable <CityResource> >(citiesForCountry); return(Ok(citiesResources)); }
public async Task <IActionResult> GetCitiesForCountry(int countryId) { if (!await _countryRepository.CountryExistAsync(countryId)) { return(NotFound()); } var citiesForCountry = await _cityRepository.GetCitiesForCountryAsync(countryId); var citiesResources = _mapper.Map <IEnumerable <CityResource> >(citiesForCountry); citiesResources = citiesResources.Select(CreateLinksForCity); var wrapper = new LinkCollectionResourceWrapper <CityResource>(citiesResources); return(Ok(CreateLinksForCitties(wrapper))); }