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