コード例 #1
0
        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));
        }
コード例 #2
0
        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)));
        }