Exemplo n.º 1
0
        public ActionResult AddCity(CityViewModel city)
        {
            try
            {
                //Mapper.Initialize(cfg => cfg.CreateMap<CityViewModel, CityDTO>());
                //var cityDto = Mapper.Map<CityViewModel, CityDTO>(city);
                //service.AddCity(cityDto);

                service.AddCity(CityViewModel.CityFromViewToDto(city));
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError(ex.Property, ex.Message);
            }
            return(RedirectToAction("Countries"));
        }