Good afternoon guys, I'd like to know if anyone can help me. My Web Service has a Get method that returns the entire List of Products, however I would like to create a method that returns a Product according to a code passed to it. At the moment all that the method with parameter is returning me is a 404 when tested on Fiddler. Any idea? Any method you have? Any help is welcome, thanks.
Code:
[Route("api/Produto")]
public class ProdutoConsultController : ApiController
{
// GET api/ProdutoConsult
public ObjectResult<uspConsultarProduto_Result> Get()
{
ControleDeEstoqueEntities entity = new ControleDeEstoqueEntities();
var result = entity.uspConsultarProduto(null);
return result;
}
// GET api/ProdutoConsult/5
public List<produto> Get(int cod)
{
ControleDeEstoqueEntities entity = new ControleDeEstoqueEntities();
List<produto> MyList = new List<produto>();
var result = from produto in entity.produto where produto.pro_cod == cod select produto;
MyList.AddRange(result);
return MyList;
}