public ActionResult RoleView(int id) { if (!UserInfo.CurUser.HasRight("系统管理-角色管理")) return Redirect("~/content/AccessDeny.htm"); Role r = (from o in db.Roles where o.Id == id select o).FirstOrDefault(); if (r == null) { r = new Role(); } else { ViewBag.Funtions = (from o in db.RoleFunctions where o.RoleId == id select o).ToList(); ViewBag.Users = (from o in db.RoleUsers where o.RoleId == id select o).ToList(); } return View(r); }
public ActionResult RoleEdit(int id, string name, string remark, FormCollection collection) { System.Threading.Thread.Sleep(10000); if (!UserInfo.CurUser.HasRight("系统管理-角色管理")) return Redirect("~/content/AccessDeny.htm"); Role r = (from o in db.Roles where o.Id == id select o).FirstOrDefault(); if (r == null) { r = new Role(); db.Roles.Add(r); } r.Name = name; r.Remark = remark; db.SaveChanges(); if (id == 0) { return Redirect("../RoleView/" + r.Id); } else { return Redirect("~/content/close.htm"); } }
public ActionResult RoleFunctionEdit(int id, FormCollection collection) { if (!UserInfo.CurUser.HasRight("系统管理-角色管理")) return Redirect("~/content/AccessDeny.htm"); Role r = (from o in db.Roles where o.Id == id select o).FirstOrDefault(); if (r == null) { r = new Role(); db.Roles.Add(r); } (from o in db.RoleFunctions where o.RoleId == id select o).ToList().ForEach(o => db.RoleFunctions.Remove(o)); string[] rights = collection["rights"].Split(','); foreach (string s in rights) { int i; int.TryParse(s, out i); if (i > 0) { db.RoleFunctions.Add(new RoleFunction { RoleId = id, FunctionId = i }); } } db.SaveChanges(); return Redirect("~/content/close.htm"); }
public ActionResult RoleEdit(int id) { if (!UserInfo.CurUser.HasRight("系统管理-角色管理")) return Redirect("~/content/AccessDeny.htm"); Role r = (from o in db.Roles where o.Id == id select o).FirstOrDefault(); if (r == null) r = new Role(); return View(r); }