コード例 #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());
        }
コード例 #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());
        }
コード例 #3
0
 public void AddCity(City city)
 {
     citiesRepository.AddCity(city);
 }