I have to method in model of my asp.net mvc project.
public JsonResult GetProductsByDepList(string depID)
{
JsonResult jr = new JsonResult();
var _product = from a in DataContext.GetProductsByDep(Convert.ToInt32(depID))
select new { ID = a.ID, ProName = a.Name };
jr.Data = _product.ToList();
jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
return jr;
}
public JsonResult GetProductByCatList(string depID, string catID)
{
JsonResult jr = new JsonResult();
var _product = from a in
DataContext.GetProductsByCat(Convert.ToInt32(depID),Convert.ToInt32(catID))
select new { ID = a.ID, ProName = a.Name };
jr.Data = _product.ToList();
jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
return jr;
}
I want to combine these 2 method, it is work the same each other, except the parameter of the function.
Any ideas please.