예제 #1
0
        public static void CreateUserGroup(UserGroup u)
        {
            if (u.GroupID == -1)
            {
                int returnval;
                object userID = DAL.DAL.ExecuteNonQuery("I_DummyUser", out returnval, DAL.DAL.Identity()).First();
                int dummyUserID = (int)userID;
                object ID = DAL.DAL.ExecuteNonQuery("I_UserGroup",
                                        DAL.DAL.Parameter("GroupName", u.GroupName),
                                        DAL.DAL.Parameter("UserID", dummyUserID), DAL.DAL.Parameter("Description", u.Description),
                                        DAL.DAL.Identity()).First();

                //fillpermissions
                
                //UserBLL.PermissionsListToDatabase(dummyUserID, u.OwnedPermissions.AllowPermissions, true);
                //UserBLL.PermissionsListToDatabase(dummyUserID, u.OwnedPermissions.DenyPermissions, false);

                if (ID != DBNull.Value && ID != null)
                {
                    u.GroupID = (int)ID;
                    u.DummyUser = dummyUserID;
                    PermissionsBLL.AddPermissions(u);
                }
                else
                {
                    throw new Exception("GroupID is null");
                }
            }

        }
예제 #2
0
 /// <summary>
 /// updates the usergroup u to the new values, creates new Usergroup if GroupID == -1
 /// Does not replace the permissions.
 /// </summary>
 /// <param name="u"></param>
 public static void EditUserGroup(UserGroup u)
 {
     if (u.GroupID != -1)
     {
         DAL.DAL.ExecuteNonQuery("U_UserGroup",
                                 DAL.DAL.Parameter("GroupID", u.GroupID), DAL.DAL.Parameter("GroupName", u.GroupName),
                                 DAL.DAL.Parameter("UserID", u.DummyUser), DAL.DAL.Parameter("Description", u.Description));
         PermissionsBLL.ReplacePermissions(u);
     }
     else
     {
         CreateUserGroup(u);
     }
 }
예제 #3
0
 public static UserGroup FillGroup(System.Data.IDataReader arg)
 {
     UserGroup ug = new UserGroup();
     //UserGroup.GroupID, GroupName, UserGroup.WinUserID, Description
     ug.GroupID = arg.GetInt32(0);
     ug.GroupName = arg.GetString(1);
     ug.DummyUser = arg.IsDBNull(2) ? -1 : arg.GetInt32(2);
     ug.Description = arg.GetString(3);
     return ug;
 }
예제 #4
0
 public static void DeleteUserGroup(UserGroup u)
 {
     DAL.DAL.ExecuteNonQuery("D_Group_ByGroupID", DAL.DAL.Parameter("GroupID", u.GroupID), DAL.DAL.Parameter("UserID", u.DummyUser));
 }
 /// <summary>
 /// Remove User u from UserGroup ug
 /// this will also remove the database action
 /// </summary>
 /// <param name="u"></param>
 /// <param name="ug"></param>
 public void RemoveUserFromGroup(User u, UserGroup ug)
 {
     if (u.UserGroupPermissions.FindFirst(x => x.ID == ug.ID) && ug.GroupUsers.FindFirst(x => x.ID == u.ID))
     {
         u.UserGroupPermissions.ToList().RemoveAll(x => x.ID == ug.ID);
         ug.GroupUsers.ToList().RemoveAll(x => x.ID == u.ID);
         //if selectedItem is a new item cancel changes, else queue a remove action to the database
         if (SelectedItem.ID == -1)
         {
             dbActions.removeUserGroupAction(u, ug);
         }
         else
         {
             dbActions.UserGroupDelayedAction(u, ug, false);
         }
     }
     
 }
        public void AddUserToGroup(User u, UserGroup ug)
        {
            if (!u.UserGroupPermissions.Contains(ug) && !ug.GroupUsers.Contains(u))
            {
                if(this is UserDetailViewModel)
                {
                    u.Changed = true;
                }
                else
                {
                    ug.Changed = true;
                }

                u.UserGroupPermissions.Add(ug);
                ug.GroupUsers.Add(u);
                dbActions.UserGroupDelayedAction(u, ug, true);
            }
        }
 protected void CreateItem(object obj)
 {
     PermissionsBase pb;
     if(this is UserDetailViewModel)
     {
         pb = new User();
     }
     else if(this is GroupDetailViewModel)
     {
         pb = new UserGroup();
     }
     else
     {
         pb = null;
     }
     AllItems.Add(pb);
     SelectedItem = pb;
 }
예제 #8
0
 public static void AddUserToGroup(User u, UserGroup g)
 {
     DAL.DAL.ExecuteNonQuery("I_GroupMember", DAL.DAL.Parameter("GroupID", g.GroupID), DAL.DAL.Parameter("UserID", u.UserID));
 }
        /// <summary>
        /// Deletes or adds the user "user" from/to UserGroup "group"
        /// </summary>
        /// <param name="user"></param>
        /// <param name="group"></param>
        /// <param name="AddDelete">true = AddUser, false = RemoveUser</param>
        public void UserGroupDelayedAction(User user, UserGroup group, bool AddDelete)
        {
            GroupAction ga = new GroupAction((UserGroup)group.GetCopy(), (User)user.GetCopy());
            ga.AddOrRemove = AddDelete;

            if (AddDelete)
            {
                //Add
                GroupActions.Add(ga);
            }
            else
            {
                //delete
                GroupActions.Remove(ga);
                GroupActions.Add(ga);
            }
        }
 public void removeUserGroupAction(User u, UserGroup ug)
 {
     GroupAction ga = new GroupAction(ug, u);
     GroupActions.Remove(ga);
 }
 public void ChangesToGroup(User AddUser, UserGroup ug, bool deleted)
 {
     StringBuilder sb = new StringBuilder();
     string del = getDel(deleted);
     sb.Append("U bent "+del+" "+(deleted?"van":"aan")+" de groep: ").Append(ug.Name).AppendLine();
     
     AddMessage(AddUser, sb.ToString());
 }
예제 #12
0
 public static void InsertUserGroup(UserGroup g)
 {
     //identity teruggeven!
     DAL.DAL.ExecuteNonQuery("I_UserGroup", DAL.DAL.Parameter("GroupName", g.GroupName), DAL.DAL.Parameter("Description", g.Description));
 }
예제 #13
0
        public static bool SelectUserGroupByName(out UserGroup ug, string groupName)
        {
            ug = null;
            try {
                
                BLLUserGroup group =
                DAL.DAL.ExecuteDataReader("S_UserGroup_ByName", FillUserGroup, DAL.DAL.Parameter("GroupName", groupName)).FirstOrDefault();
                ug = FillUserGroupPermissions(group);
                return true;
            }
            catch (Exception)
            {
                return false;
            }

        }
예제 #14
0
        public static UserGroup FillUserGroupPermissions(BLLUserGroup group)
        {
            UserGroup ug = new UserGroup();
            ug.GroupName = group.GroupName;
            ug.GroupID = group.GroupID;
            ug.Description = group.Description;
            ug.DummyUser = group.DummyUserID;
            User Dummy = null;
            if (SelectUser(out Dummy, group.DummyUserID))
            {
                ug.OwnedPermissions = Dummy.OwnedPermissions;
            }

            return ug;
        }
예제 #15
0
 public static void DeleteUserFromGroup(User u, UserGroup g)
 {
     DAL.DAL.ExecuteNonQuery("D_GroupMember_ByGroupID_ByUserID", DAL.DAL.Parameter("GroupID", g.GroupID), DAL.DAL.Parameter("UserID", u.UserID));
 }
 public GroupAction(UserGroup group, User addUser)
 {
     Group = group;
     AddUser = addUser;
 }
예제 #17
0
 public override PermissionsBase GetCopy()
 {
     UserGroup copy = new UserGroup();
     copy.InstanceID = InstanceID;
     copy.GroupName = GroupName;
     copy.GroupID = GroupID;
     copy.OwnedPermissions = OwnedPermissions.GetCopy();
     copy.Description = Description;
     copy.DummyUser = DummyUser;
     return copy;
 }
 private void DeleteUserFromGroup(object obj)
 {
     RemoveUserFromGroup(SelectedItem as User, SelectedGroup);
     UserGroups.Remove(SelectedGroup);
     SelectedGroup = null;
 }