close
[HttpPost]
public JsonResult GetProductsJSONResult()
{
ProductService service = new ProductService();
var data = service.FetchAll();
List<Dictionary<string, object>> ja = new List<Dictionary<string, object>>();
foreach (var item in data)
{
Dictionary<string, object> jo = new Dictionary<string, object>();
jo.Add("ProductID", item.ProductID);
jo.Add("ProductName", item.ProductName);
jo.Add("CategoryID", item.CategoryID);
jo.Add("CategoryName", item.Category.CategoryName);
jo.Add("SupplierID", item.SupplierID);
jo.Add("CompanyName", item.Supplier.CompanyName);
ja.Add(jo);
}
return Json(ja);
}
全站熱搜
留言列表