public IHttpActionResult Delete(int id) { try { var entityInDb = _clienteBusiness.GetById(id); //Verifica se objeto existe if (entityInDb == null) { return(NotFound()); } if (_clienteBusiness.Delete(id)) { //Monta response _result = Ok(Retorno <bool> .Criar(true, "Deleção Realizada Com Sucesso", true)); //Retorna o response return(_result); } else { return(BadRequest("Nenhum registro deletado. Verifique os dados enviados.")); } } catch (Exception) { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public IActionResult Delete(Guid id) { var result = _business.Delete(id); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public HttpResponseMessage Delete(ClienteViewModel clienteViewModel) { try { return(Request.CreateResponse(HttpStatusCode.OK, m_ClienteBusiness.Delete(clienteViewModel))); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, string.Format("Error:{0}!", ex.Message))); } }
public void Deletar(int id) { Cliente cliente = clienteBusiness.GetById(id); if (cliente != null) { clienteBusiness.Delete(cliente); } else { throw new KeyNotFoundException("Id não encontrado"); } }
public async Task <IActionResult> Delete(int id) { try { if (id <= 0) { return(NotFound()); } await _clienteBusiness.Delete(id); return(Ok("Cliente removido com sucesso.")); } catch (Exception ex) { return(BadRequest($"{ex.Message} - {ex.InnerException}")); } }