public IActionResult GetPointsOfInterest(int cityId) { try { if (!_repository.CityExists(cityId)) { _logger.LogInformation($"City with id {cityId} wasn't found when accessing points of interest."); return(NotFound()); } var pointsOfInterestForCity = _repository.GetPointsOfInterestForCity(cityId); var pointsOfInterestForCityResults = Mapper.Map <IEnumerable <PointOfInterestDTO> >(pointsOfInterestForCity); return(Ok(pointsOfInterestForCityResults)); } catch (Exception ex) { _logger.LogCritical($"Exception while getting points of interest for city with id {cityId}.", ex); return(StatusCode(500, "A problem happened while handling your request.")); } }
/// <summary> /// Check if city name already /// </summary> /// <param name="countryId"></param> /// <param name="cityName"></param> /// <returns></returns> public async Task <bool> CityExists(int cityId) { return(await _citiesRepo.CityExists(cityId)); }