public ActionResult DeletePrivilege() { using (MyDB mydb = new MyDB()) { EntityObjectLib.Privilege p = mydb.Privileges.Find(Request.Form["ID"]); mydb.Privileges.Remove(p); mydb.SaveChanges(); } return(Json(new { success = true })); }
public ActionResult CreatePrivilege() { using (MyDB mydb = new MyDB()) { EntityObjectLib.Privilege p = getPrivilege(Request, mydb); p.ID = Guid.NewGuid().ToString(); mydb.Privileges.Add(p); mydb.SaveChanges(); } return(Json(new { success = true })); }
public ActionResult UpdatePrivilege() { using (MyDB mydb = new MyDB()) { EntityObjectLib.Privilege p = getPrivilege(Request, mydb); //mydb.Modules.Attach(p); //mydb.Entry<EntityObjectLib.Privilege>(p).State = System.Data.EntityState.Modified; mydb.SaveChanges(); } return(Json(new { success = true })); }
private EntityObjectLib.Privilege getPrivilege(HttpRequestBase request, MyDB mydb) { EntityObjectLib.Privilege p = mydb.Privileges.Find(Request.Form["ID"]); if (p == null) { p = new EntityObjectLib.Privilege(); } p.privilegeCode = Request.Form["privilegeCode"]; p.privilegeName = Request.Form["privilegeName"]; p.needAuth = Request.Form["needAuth"] != null; p.isMenuEntry = Request.Form["isMenuEntry"] != null; p.privilegeDescription = Request.Form["privilegeDescription"]; p.resource = mydb.Resources.Find(Request.Form["resourceID"]); return(p); }
public ActionResult getPrivilege() { using (MyDB mydb = new MyDB()) { EntityObjectLib.Privilege p = mydb.Privileges.Find(Request.Form["ID"]); return(Json(new { success = true, data = new { ID = p.ID, privilegeCode = p.privilegeCode, privilegeName = p.privilegeName, p.isMenuEntry, p.needAuth, privilegeDescription = p.privilegeDescription, resourceID = p.resource.ID } } )); } }
private EntityObjectLib.Privilege getPrivilege(HttpRequestBase request,MyDB mydb) { EntityObjectLib.Privilege p = mydb.Privileges.Find(Request.Form["ID"]); if (p == null) { p = new EntityObjectLib.Privilege(); } p.privilegeCode = Request.Form["privilegeCode"]; p.privilegeName = Request.Form["privilegeName"]; p.needAuth = Request.Form["needAuth"] != null; p.isMenuEntry = Request.Form["isMenuEntry"] != null; p.privilegeDescription = Request.Form["privilegeDescription"]; p.resource = mydb.Resources.Find(Request.Form["resourceID"]); return p; }