public IActionResult Create(IngredienteVM ingrediente) { if (ModelState.IsValid) { _service.Add(ingrediente.ToModel()); return(RedirectToAction("Index")); } return(View(ingrediente)); }
public JsonResult Add(Application.Ingrediente.ViewModel.AddIngrediente vmodel) { try { if (ModelState.IsValid) { _ingredienteService.Add(vmodel); if (ValidOperation()) { return(Json(new { result = true, list = _ingredienteService.List(), message = "Inserido com sucesso!" })); } } } catch (Exception e) { } AddMessages(); return(Json(new { result = false, list = "", message = "Erro ao inserir!" })); }