Example #1
0
 public bool Cadastrar(Cliente cliente, string cpf)
 {
     try
     {
         return(_clienteService.Cadastrar(cliente, cpf));
     }
     catch (RegistroExisteException e)
     {
         throw new RegistroExisteException(e.Message);
     }
     catch (ConcorrenciaBancoException e)
     {
         throw new ConcorrenciaBancoException(e.Message);
     }
 }
        public IActionResult Cadastrar([FromBody] ClienteViewModel clienteVm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var cliente = _service.Cadastrar(clienteVm);

            if (_errorHandlerService.Errors.Any())
            {
                return(BadRequest(_errorHandlerService.Errors));
            }

            return(CreatedAtRoute("ObterCliente", new { id = cliente.Id }, cliente));
        }
Example #3
0
 public IActionResult Cadastrar(Cliente entidade)
 {
     return(Ok(_servico.Cadastrar(entidade)));
 }
Example #4
0
 public async Task Cadastrar([FromBody] CadastrarModel cadastro)
 {
     await _cliente.Cadastrar(cadastro);
 }