I've been following this tutorial: http://ift.tt/z4Im45 to create my API, and the logic behind it is pretty much the same.
At the moment /api/products gets all products, and GetProduct /api/products/id, gets only 1 product based on the id.
Now my problem is, I'd like to get all products with e.g. ID 1 This is the code used for getting just one product:
public IHttpActionResult GetProduct(int id) {
var product = products.FirstOrDefault((p) => p.Id == id);
if (product == null) {
return NotFound();
}
return Ok(product);
}
public IEnumerable<Product> GetAllProducts() {
return products;
}
Any help appreciated.
No comments:
Post a Comment