Ejemplo n.º 1
0
        public IActionResult CreateCity([FromBody] CityDTO city)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var cityToReturn = Mapper.Map <City>(city);

            _repository.CreateCity(cityToReturn);
            return(Ok(city));
        }
Ejemplo n.º 2
0
        public ActionResult <CityInfo> CreateCity(CityInfo city)
        {
            CityModel cityModel = new(){
                Id          = city.Id,
                Name        = city.Name,
                Country     = city.Country,
                Capital     = city.Capital,
                CreatedDate = DateTime.Now,
            };

            citiesRepository.CreateCity(cityModel);

            return(CreatedAtAction(nameof(GetById), new { id = cityModel.Id }, cityModel.AsDto()));
        }