Good afternoon guys, I do not know why my parameter is not recognized, can you help me? The value does not arrive in C # but is present in the angle C #
[HttpGet]
[Route("carregarUsuarioPorId")]
public HttpResponseMessage BuscarUsuarioPorId()
{
try
{
WSS_RetornoListaDTO<Usuario> wss = new WSS_RetornoListaDTO<Usuario>();
int idUser = 0;
var req = Request.GetQueryNameValuePairs();
if (req != null)
{
foreach (var parameter in req)
{
if (parameter.Key.Equals("id"))
idUser = int.Parse(parameter.Value.ToString());
}
}
usuarioDAO = new UsuarioDAO();
wss.resultado = usuarioDAO.BuscarUsuarioPorId(idUser);
if (wss.resultado.Count > 0)
{
wss.codRetorno = 200;
wss.msgRetorno = "Sucesso";
return Request.CreateResponse<WSS_RetornoListaDTO<Usuario>>(HttpStatusCode.OK, wss);
}
else
return Request.CreateResponse(HttpStatusCode.NoContent, "Usuario não localizado");
}
catch (Exception e)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, "ERRO - " + e.Message);
}
}
Parameter call:
getUserPorId: function (idUser) {
var id = [];
id[0] = idUser;
return
$http.get('http://localhost:61223/usuario/carregarUsuarioPorId',id)
.then(function (response) {
return response.data;
});
},