コード例 #1
0
        public void UpdateUserPrivileges(UserPrivilegeTableAdapter userPrivilegeTableAdapter, int userId, List <int> privilegeIds)
        {
            if (ListUtil.IsEmpty(privilegeIds))
            {
                userPrivilegeTableAdapter.DeleteUserPrivileges("0", userId);
            }
            else
            {
                userPrivilegeTableAdapter.DeleteUserPrivileges(StringUtil.JoinWithCommas(privilegeIds), userId);

                foreach (int privilegeId in privilegeIds)
                {
                    userPrivilegeTableAdapter.InsertUserPrivilegeIfNotExists(userId, privilegeId, 1);
                }
            }
        }