0
While trying to delete the record, I get this message, all other operations is working.
The code:
//http://www.sistemaguardiao.com.br/webapi/api/AspNetWebApi/deletar/jogo/4512/5
//http://localhost:7630/api/AspNetWebApi/deletar/jogo/4512/5
//precisa usar o postman com opção delete formato json
[HttpDelete]
[Route("deletar/jogo/{nJogo}/{idusuario}")]
public HttpResponseMessage Deletar(int nJogo, int idusuario)
{
try
{
var tTabela = new JogoDetalheAplicacao();
var resultado = tTabela.Excluir(nJogo, idusuario);
return Request.CreateResponse(HttpStatusCode.OK, resultado);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
}
}
In applying:
public bool Excluir(int nJogo, int idusuario)
{
var retorno = 0;
var strQuery = string.Format("DELETE FROM TB_JOGO_DETALHE_TEMP WHERE NUMERO_JOGO = {0} AND IDUSUARIO = {1}; SELECT NUMERO_JOGO FROM TB_JOGO_DETALHE_TEMP WHERE NUMERO_JOGO = {0} AND IDUSUARIO = {1}", nJogo, idusuario);
using (contexto = new Contexto())
{
var reader = contexto.ExecutaComandoComRetorno(strQuery);
while (reader.Read())
{
retorno = Convert.ToInt32(reader["NUMERO_JOGO"]);
}
reader.Close();
}
if (retorno == 0)
return true;
return false;
}
http://www.sistemaguardiao.com.br/webapi/api/AspNetWebApi/deletar/jogo/4512/5
http://www.sistemaguardiao.com.br/webapi/api/AspNetWebApi/datahora/consulta
Reading the first link you are trying to delete using the GET method. But it needs to show code node as you are doing.
– leopiazzoli
@leopiazzoli, I’m using Delete, I posted the code is the address that can be tested, thank you
– Harry