public IActionResult Post([FromBody] CityViewModel city) { if (!ModelState.IsValid) { return(BadRequest()); } if (_citiesRepository.GetCityByName(city.City) != null) { return(BadRequest()); } _citiesRepository.AddCity(city); return(Ok()); }
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); }