public IActionResult CreatePointOfInterest(int cityId, [FromBody] PointOfInterest pointOfInterest) { if (pointOfInterest == null) { _logger.LogDebug("POI is not defined"); return(BadRequest()); } if (!_cityInfoRepository.CityExists(cityId)) { _logger.LogDebug($"city with id {cityId} could not be found"); return(NotFound()); } var newPointOfInterestEntity = Mapper.Map <PointOfInterestEntity>(pointOfInterest); _cityInfoRepository.AddPointOfInterestForCity(cityId, newPointOfInterestEntity); if (!_cityInfoRepository.Save()) { return(StatusCode(500, "An error occurred attempting to create POI")); } var createdPointOfInterest = Mapper.Map <PointOfInterestDto>(newPointOfInterestEntity); return(CreatedAtRoute("GetPointOfInterest", new { cityId = cityId, poiId = createdPointOfInterest.Id }, createdPointOfInterest)); }