示例#1
0
        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));
        }
示例#2
0
        public IActionResult Post([FromBody] ContaViewModel contaViewModel)
        {
            if (!ModelStateValida())
            {
                return(Response());
            }

            contaViewModel = _contaAppService.Adicionar(contaViewModel);
            return(Response(contaViewModel));
        }
示例#3
0
        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));
        }
示例#4
0
 public void CriarConta([FromBody] ContaViewModel contaViewModel)
 {
     _contaAppService.Adicionar(contaViewModel);
 }