Exemple #1
0
        public IActionResult Post([FromBody] CityViewModel city)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (_citiesRepository.GetCityByName(city.City) != null)
            {
                return(BadRequest());
            }

            _citiesRepository.AddCity(city);
            return(Ok());
        }
Exemple #2
0
        public IActionResult Post([FromBody] CityViewModel cityViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (_citiesRepository.GetCityByName(cityViewModel.Name) != null)
            {
                return(BadRequest());
            }

            var city = new City();

            city.InjectFrom(cityViewModel);

            _citiesRepository.AddCity(city);

            return(Ok());
        }
 public void AddCity(City city)
 {
     citiesRepository.AddCity(city);
 }