Reputation: 1
public List<ProductlistModel> GetProductList(int catId)
{
List<ProductlistModel> products = db.ProductLists.Where(c=>c.CategoryID==catId).Select(s => new ProductlistModel()
}
This is my product repository in Business Logic.
I am trying to pass catId
in controller but it is throwing error.
private ProductRepository pr = new ProductRepository();
public ActionResult Index()
{
List<ProductlistModel> products = pr.GetProductList(catId);
return View(products);
}
How to access catId
in controller?
Upvotes: 0
Views: 40
Reputation: 11
Pass catId as parameter. You can handle it by passing parameter as string and convert it to int before passing to the Function or Procedure of Model
Upvotes: 0
Reputation: 4862
For example:
public ActionResult Index(int? catId)
{
// TODO: check catId for null
List<ProductlistModel> products = pr.GetProductList(catId.Value);
return View(products);
}
Upvotes: 1