public IActionResult Post(ClienteAddViewModel model) { try { clienteApplicationService.Add(model); return(Ok( new { Mensagem = "Cliente cadastrado com sucesso.", Cliente = model })); } catch (EmailDeveSerUnicoException e) { return(StatusCode(403, e.Message)); } catch (CpfDeveSerUnicoException e) { return(StatusCode(403, e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public IActionResult Post(CreateClienteCommand command) { try { clienteApplicationService.Add(command); return(Ok(new { Message = "Cliente cadastrado com sucesso" })); } catch (Exception e) { return(StatusCode(500, e.Message));; } }
public ActionResult Post([FromBody] ClienteDTO clienteDTO) { try { if (clienteDTO == null) { return(NotFound()); } _clienteApp.Add(clienteDTO); return(Ok("Cliente cadastrado com sucesso")); } catch (Exception ex) { throw; } }
public ActionResult Post([FromBody] ClienteDTO clienteDTO) { try { if (clienteDTO == null) { return(NotFound()); } _clienteApplicationService.Add(clienteDTO); return(Ok("Cliente Cadastrado com sucesso!")); } catch (Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $" {ex.Message}")); } }
public async Task <IActionResult> Create(ClienteViewModel cliente) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(View(cliente)); } var commandResult = await _clienteApplicationService.Add(cliente); if (commandResult.Success) { NotifyCommandResultSuccess(); return(RedirectToAction(nameof(Index))); } else { NotifyCommandResultErrors(commandResult.Errors); } return(View(cliente)); }