Пример #1
0
        public IActionResult AddCity([FromBody] AddCityModel addCityModel)
        {
            if (addCityModel == null)
            {
                return(BadRequest());
            }

            int newId = _dataStore.GetNewId();

            var city = new City(
                newId,
                addCityModel.Name,
                addCityModel.Description,
                addCityModel.NumberOfPoi);

            _dataStore.Cities.Add(city);

            var getCityModel = new GetCityModel(
                newId,
                addCityModel.Name,
                addCityModel.Description,
                addCityModel.NumberOfPoi);

            return(CreatedAtAction(
                       "GetCity",
                       new { id = newId },
                       getCityModel));
        }