So I have this code:
public ActionResult Agregar(int id)
{
Producto producto = db.Productos.Find(id);
var list = new List<Carrito> {
new Carrito { ProductId = producto.ID, Cantidad = 1, PrecioUnitario = producto.Precio }
};
return View(list);
}
and I pass the variable list to the View, the problem is, I don't know how to access ProductId or Cantidad
Any idea how to do this?
Also, let's suppose the variable list has multiple objects, how to print the result of every object through a foreach