Example #1
0
        public IActionResult UpdateCity(int id, bool includePointsOfInterest)
        {
            var cityToUpdate = _repository.GetCity(id, includePointsOfInterest);

            if (cityToUpdate == null)
            {
                return(NotFound());
            }

            _repository.UpdateCity(cityToUpdate);
            return(NoContent());
        }
        public ActionResult UpdateCity(CityInfo city)
        {
            CityModel currentCity = citiesRepository.GetById(city.Id);

            if (currentCity is null)
            {
                return(NotFound());
            }

            CityModel updatedCity = new() {
                Id          = currentCity.Id,
                Name        = city.Name,
                Country     = city.Country,
                Capital     = city.Capital,
                CreatedDate = currentCity.CreatedDate
            };

            citiesRepository.UpdateCity(updatedCity);

            return(NoContent());
        }