I'm having trouble to solve this problem.
The current request for action 'ListProducts' on controller type 'ProductController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult ListProducts(System.Nullable`1[System.Int32]) on type Nettbutikk.Controllers.ProductController System.Web.Mvc.ActionResult ListProducts(Int32, System.String) on type Nettbutikk.Controllers.ProductController
Anyone out there who can help me?
Context:
public List<Product> getAll(int id, string something)
{
var db = new DatabaseContext();
List<Product> allProducts = new List<Product>();
var products = db.Products.Where(p => p.SubCategoriesId == id).ToList();
foreach (var p in products)
{
var product = new Product()
{
itemnumber = p.Id,
name = p.Name,
description = p.Description,
price = p.Price,
volum = p.Volum,
producer = p.Producers.Name,
pricePerLitre = pricePerLitre(p.Price, p.Volum),
category = p.SubCategories.Categories.Name,
subCategory = p.SubCategories.Name,
country = p.Countries.Name
};
allProducts.Add(product);
}
return allProducts;
}
Controller:
public ActionResult ListProducts(int? id)
{
var db = new DBProduct();
List<Product> listOfProducts;
listOfProducts = db.getAll(id);
return View(listOfProducts);
}
public ActionResult ListProducts(int id, string something)
{
var db = new DBProduct();
List<Product> listOfProducts;
listOfProducts = db.getAll(id,tull);
return View(listOfProducts);
}
And the View:
<a href='@Url.Action("ListProducts", "Product", new { id = 1, tull = "" })'>sub category</a>