I have the following code and I want to get a return on the result variable if it is true or false, how could I do this?
//http://localhost:1608/api/ApiCidade/deletar/cliente/10
[HttpDelete]
[Route("deletar/cliente/{id:int}")]
public HttpResponseMessage ClienteDeletar(int id)
{
try
{
var resultado = true;
var tCliente = new ClienteAplicacao();
tCliente.Excluir(id);
return Request.CreateResponse(HttpStatusCode.OK, resultado);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
}
}
In the Application I have:
public void Excluir(int id)
{
var strQuery = string.Format("DELETE FROM clientes WHERE id= {0}", id);
using (contexto = new Contexto())
{
contexto.ExecutaComando(strQuery);
}
}