public ActionResult Delete(int id) { try { if (id == 0) { return(NotFound()); } var clienteDTO = _clienteApplicationService.GetById(id); if (clienteDTO != null) { _clienteApplicationService.Remove(clienteDTO); return(Ok("Cliente Removido com sucesso!")); } else { return(NotFound()); } } catch (Exception ex) { throw ex; } }
public ActionResult Delete([FromBody] ClienteDTO clienteDTO) { if (clienteDTO == null) { return(NotFound()); } _clienteApp.Remove(clienteDTO); return(Ok("Cliente removido com sucesso")); }
public async Task <IActionResult> Delete(Guid id, ClienteViewModel cliente) { var commandResult = await _clienteApplicationService.Remove(cliente); if (commandResult.Success) { NotifyCommandResultSuccess(); return(RedirectToAction(nameof(Index))); } else { NotifyCommandResultErrors(commandResult.Errors); } return(View(cliente)); }
public IActionResult Delete([FromServices] IClienteApplicationService service, ClienteModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelStateValidaton.GetErrors(ModelState))); } try { service.Remove(model); return(Ok()); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public IActionResult Delete(int id) { try { var command = new DeleteClienteCommand { Id = id }; clienteApplicationService.Remove(command); return(Ok(new { Message = "Cliente excluido com sucesso." })); } catch (Exception e) { return(StatusCode(500, e.Message)); } }