Example #1
0
 public static void AddUser(string[] arrId)
 {
     foreach (string Id in arrId)
     {
         Guid uId  = new Guid(Id);
         User user = UserNotInRoleCollection.Where(u => u.Id == uId).Single();
         UserList.Add(user);
         UserNotInRoleCollection.Remove(user);
         UserInRoleList.Add(new UserInRole {
             RoleId = Args.Role.Id, UserId = uId
         });
     }
 }
Example #2
0
        public static void UserDelete(string[] arrId)
        {
            foreach (string id in arrId)
            {
                Guid idUser = new Guid(id);
                User user   = UserList.Where(u => u.Id == idUser).Single();
                UserList.Remove(user);

                UserInRole userInRole = UserInRoleList.Where(u => u.UserId == idUser && u.RoleId == Args.Role.Id).Single();
                UserInRoleList.Remove(userInRole);

                UserNotInRoleCollection.Add(user);
                UserNotInRoleList.Add(userInRole);
            }
        }
Example #3
0
        public static void Save()
        {
            //list of user added
            IEnumerable <UserInRole> addedUsers   = UserInRoleList.Except(CopyOfUserInRoleList, new UserInRoleEqualityComparer());
            IEnumerable <UserInRole> deletedUsers = CopyOfUserInRoleList.Except(UserInRoleList, new UserInRoleEqualityComparer());

            foreach (UserInRole u in addedUsers)
            {
                CopyOfUserInRoleList.AddDB(u);
            }
            List <UserInRole> list = deletedUsers.ToList <UserInRole>();

            for (int i = 0; i < list.Count; i++)
            {
                UserInRole u = list[i];
                CopyOfUserInRoleList.RemoveDB(u);
            }
        }