public void UpdateRoleController(Role role, List<int> powerIdList) { List<ControllerAction> list = new List<ControllerAction>(); role.ControllerActions.Where(c => powerIdList.Contains(c.ID)).ToList().ForEach(a => { role.ControllerActions.Remove(a); }); int id; for (int i = 0; i < powerIdList.Count; i++) { ControllerAction controller = new ControllerAction(); id = powerIdList[i]; controller = _db.ControllerActions.SingleOrDefault(a => a.ID == id); list.Add(controller); } role.ControllerActions = list; _db.SaveChanges(); }
public void SaveRole(Role role, List<int> powerIdList) { List<ControllerAction> list = new List<ControllerAction>(); int id; for (int i = 0; i < powerIdList.Count; i++) { ControllerAction controller = new ControllerAction(); id = powerIdList[i]; controller = _db.ControllerActions.SingleOrDefault(a => a.ID == id); list.Add(controller); } role.ControllerActions = list; _db.Roles.Add(role); _db.SaveChanges(); }
public ControllerAction SaveContro(ControllerAction controllerAction) { _db.ControllerActions.Add(controllerAction); _db.SaveChanges(); return controllerAction; }