1
I have an application that manages the Distributor and its Products. I want to list only the products of the Distributor I selected, but in case everything is appearing.
I tried to do so:
public ActionResult ListarProdutosDistribuidoras(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Produto produto = db.Produtos.Find(id);
if (produto == null)
{
return HttpNotFound();
}
var produtos = db.Produtos.Include(p => p.Pessoa.PessoaID);
return View(produtos.ToList());
}
the distributor is primary key?
– Gustavo Correia
Opa, yes the distributor is primary key.
– Gabriel Siqueira
the code is cloudy, what would be this id that it receives as parameter and which field is the distributor ai? Person would be the distributor?
– Gustavo Correia
Does the product have the code of the distributor in which it belongs? Post the Models Product and Distributor, to see how the relationship is.
– Randrade