public async Task <IActionResult> Cadastrar(RestauranteInsertViewModel restauranteViewModel) { var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <RestauranteInsertViewModel, RestauranteDTO>(); }); IMapper mapper = configuration.CreateMapper(); RestauranteDTO restaurante = mapper.Map <RestauranteDTO>(restauranteViewModel); try { await _restauranteService.Insert(restaurante); return(RedirectToAction("Index", "Restaurante")); } catch (Exception ex) { ViewBag.ErroGenerico = ex.Message; } return(View()); }