public ActionResult AjaxListStore(jQueryDataTableParamModel param) { DataTables table; User user = (User)Session["CurrentUser"]; user = db.Users.Find(user.UserID); if (db.Roles.Find(1).Users.Contains(user) || db.Roles.Find(4).Users.Contains(user)) { table = new DataTables( ((IObjectContextAdapter)new EntityContext()).ObjectContext, "store", new string[] { "Stores.StoreName", "Stores.Address", "Stores.Region.RegionName", "Stores.StoreID" }, "EntityContext.Stores", "AjaxListStore", "SalesRecord", new string[] { "销售点名", "详细地址", "所属片区", "操作" }); } else { table = new DataTables( ((IObjectContextAdapter)new EntityContext()).ObjectContext, "store", new string[] { "s.StoreName", "s.Address", "s.Region.RegionName", "s.StoreID" }, "FLATTEN(select value Users.StoresBelonged from EntityContext.Users where Users.UserID = " + user.UserID + ") as s", "AjaxListStore", "SalesRecord", new string[] { "销售点名", "详细地址", "所属片区", "操作" }); } ViewBag.DataTable = table; return Json(table.AjaxHandler(param), JsonRequestBehavior.AllowGet); }
public ActionResult Index() { DataTables table; User user = (User)Session["CurrentUser"]; user = db.Users.Find(user.UserID); if (db.Roles.Find(1).Users.Contains(user) || db.Roles.Find(4).Users.Contains(user)) { table = new DataTables( ((IObjectContextAdapter)new EntityContext()).ObjectContext, "store", new string[] { "s.StoreName", "s.Address", "s.Region.RegionName", "s.StoreID" }, "FLATTEN(select value Users.StoresBelonged from EntityContext.Users where Users.UserID = " + user.UserID + ") as s", "AjaxListStore", "SalesRecord", new string[] { "销售点名", "详细地址", "所属片区", "操作" }, new string[] { "20%", "45%", "15%", "20%" }); } else { table = new DataTables( ((IObjectContextAdapter)new EntityContext()).ObjectContext, "store", new string[] { "Stores.StoreName", "Stores.Address", "Stores.Region.RegionName", "Stores.StoreID" }, "EntityContext.Stores", "AjaxListStore", "SalesRecord", new string[] { "销售点名", "详细地址", "所属片区", "操作" }, new string[] { "20%", "45%", "15%", "20%" }); } ViewBag.DataTable = table; return View(); }