public ActionResult <List <CityDTO> > SearchCities(string cityName) { if (string.IsNullOrWhiteSpace(cityName) || cityName.Length < 3) { return(BadRequest(new ArgumentException("O nome da cidade deve ter no mÃnimo 3 caracteres."))); } FoundCitiesDTO foundCities = this._externalCityService.SearchCitiesByName(cityName); var convertedCities = foundCities.list .Select(foundCity => _mapper.Map <CityDTO>(foundCity)) .ToList(); return(Ok(convertedCities)); }
public ActionResult <List <CityDTO> > SearchCities(string cityName) { if (string.IsNullOrWhiteSpace(cityName) || cityName.Length < 3) { return(BadRequest(new ArgumentException("Por favor digite 3 ou mais caracteres para buscar a cidade."))); } FoundCitiesDTO foundCities = this._externalCityService.GetCitiesByName(cityName); List <CityDTO> convertedCities = foundCities.list .Select(foundCity => _autoMapper.Map <CityDTO>(foundCity)) .ToList(); return(Ok(convertedCities)); }