Example #1
0
        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();
        }
Example #2
0
 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();
 }
Example #3
0
 public ControllerAction SaveContro(ControllerAction controllerAction)
 {
     _db.ControllerActions.Add(controllerAction);
     _db.SaveChanges();
     return controllerAction;
 }