public async Task <ActionResult <CityDto[]> > GetCities( [FromQuery] bool includeCountry = false, [FromQuery] int minPopulation = 0, [FromQuery] int maxPopulation = 0) { try { var cities = await _cityRepo.GetCities(includeCountry, minPopulation, maxPopulation); var mappedCities = _mapper.Map <CityDto[]>(cities); for (var index = 0; index < mappedCities.Count(); index++) { var cityLinks = CreateLinksForCities(mappedCities[index].CityId); var attractionLinks = CreateLinksForCityAttractions(cities[index]); mappedCities[index].Add(cityLinks, attractionLinks); } return(Ok(mappedCities)); } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}")); } }
public async Task <ActionResult <CityModel[]> > GetCities([FromQuery] bool includeAttractions = false) { try { var results = await _cityRepo.GetCities(includeAttractions); return(Ok(results)); } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}")); } }
public IHttpActionResult GetCities() { var data = cityRepo.GetCities(); return(Ok(data)); }
public IQueryable <CityDTO> GetCities() { return(_cityRepo.GetCities().Select(CityDTO.Create())); }