public ActionResult Create(ContaViewModel contaViewModel) { if (ModelState.IsValid) { contaViewModel = _clienteAppService.Adicionar(contaViewModel); if (!contaViewModel.ValidationResult.IsValid) { foreach (var erro in contaViewModel.ValidationResult.Erros) { ModelState.AddModelError(string.Empty, erro.Message); } return(View(contaViewModel)); } if (!contaViewModel.ValidationResult.Message.IsNullOrWhiteSpace()) { ViewBag.Sucesso = contaViewModel.ValidationResult.Message; return(View(contaViewModel)); } return(RedirectToAction("Index")); } return(View(contaViewModel)); }
public IActionResult Post([FromBody] ContaViewModel contaViewModel) { if (!ModelStateValida()) { return(Response()); } contaViewModel = _contaAppService.Adicionar(contaViewModel); return(Response(contaViewModel)); }
public ActionResult Create(ContaViewModel contaViewModel) { if (ModelState.IsValid) { _contaAppService.Adicionar(contaViewModel); return(RedirectToAction("Index")); } ViewBag.ClienteId = new SelectList(_contaAppService.ObterTodos(), "Id", "Nome", contaViewModel.ClienteId); return(View(contaViewModel)); }
public void CriarConta([FromBody] ContaViewModel contaViewModel) { _contaAppService.Adicionar(contaViewModel); }