Index: branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
===================================================================
--- branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs	(revision 15630)
+++ branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs	(revision 15643)
@@ -507,5 +507,8 @@
           } else {
             var addedJobResourceIds = resourceIds.Except(job.AssignedJobResources.Select(x => x.ResourceId));
-            var removedJobResourceIds = job.AssignedJobResources.Select(x => x.ResourceId).Except(resourceIds);
+            var removedJobResourceIds = job.AssignedJobResources
+              .Select(x => x.ResourceId)
+              .Except(resourceIds)
+              .ToArray();
             
             // remove resource assignments
@@ -855,5 +858,5 @@
       AuthorizationManager.AuthorizeForProjectAdministration(projectId);
       var pm = PersistenceManager;
-      using (new PerformanceLogger("GrantProjectPermissions")) {
+      using (new PerformanceLogger("SaveProjectPermissions")) {
         var projectDao = pm.ProjectDao;
         var projectPermissionDao = pm.ProjectPermissionDao;
@@ -863,7 +866,6 @@
           var project = projectDao.GetById(projectId);
           if (project == null) return;
-          //if (project.ProjectPermissions == null) project.ProjectPermissions = new System.Data.Linq.EntitySet<DA.ProjectPermission>();
-          var projectPermissions = project.ProjectPermissions.Select(x => x.GrantedUserId);
-          var addedPermissions = grantedUserIds.Except(projectPermissions);
+          var projectPermissions = project.ProjectPermissions.Select(x => x.GrantedUserId).ToArray();
+          //var addedPermissions = grantedUserIds.Except(projectPermissions);
           var removedPermissions = projectPermissions.Except(grantedUserIds);
 
@@ -874,5 +876,7 @@
           } else {
             assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, removedPermissions);
-            foreach(var item in project.ProjectPermissions.ToList().Where(x => removedPermissions.Contains(x.GrantedUserId))) {
+            foreach(var item in project.ProjectPermissions
+              .Where(x => removedPermissions.Contains(x.GrantedUserId))
+              .ToList()) {
               project.ProjectPermissions.Remove(item);
             }
@@ -907,5 +911,7 @@
                 p.ProjectPermissions.Clear();
               } else {
-                foreach(var item in p.ProjectPermissions.ToList().Where(x => removedPermissions.Contains(x.GrantedUserId))) {
+                foreach(var item in p.ProjectPermissions
+                  .Where(x => removedPermissions.Contains(x.GrantedUserId))
+                  .ToList()) {
                   p.ProjectPermissions.Remove(item);
                 }
@@ -979,5 +985,5 @@
       AuthorizationManager.AuthorizeForProjectResourceAdministration(projectId, resourceIds);
       var pm = PersistenceManager;
-      using (new PerformanceLogger("AssignProjectResources")) {
+      using (new PerformanceLogger("SaveProjectResourceAssignments")) {
         var projectDao = pm.ProjectDao;
         var assignedProjectResourceDao = pm.AssignedProjectResourceDao;
@@ -985,6 +991,6 @@
         pm.UseTransaction(() => {
           var project = projectDao.GetById(projectId);
-          var assignedResources = project.AssignedProjectResources.Select(x => x.ResourceId);
-          var addedAssignments = resourceIds.Except(assignedResources);
+          var assignedResources = project.AssignedProjectResources.Select(x => x.ResourceId).ToArray();
+          //var addedAssignments = resourceIds.Except(assignedResources);
           var removedAssignments = assignedResources.Except(resourceIds);
 
@@ -992,10 +998,10 @@
           if (reassign) {
             assignedJobResourceDao.DeleteByProjectId(project.ProjectId);
-            //assignedProjectResourceDao.DeleteByProjectIds(new List<Guid> { projectId });
             project.AssignedProjectResources.Clear();
           } else {
             assignedJobResourceDao.DeleteByProjectIdAndResourceIds(projectId, removedAssignments);
-            //assignedProjectResourceDao.DeleteByProjectIdAndResourceIds(projectId, removedAssignments);
-            foreach (var item in project.AssignedProjectResources.ToList().Where(x => removedAssignments.Contains(x.ResourceId))) {
+            foreach (var item in project.AssignedProjectResources
+              .Where(x => removedAssignments.Contains(x.ResourceId))
+              .ToList()) {
               project.AssignedProjectResources.Remove(item);
             }
@@ -1030,5 +1036,12 @@
               } else {
                 //assignedProjectResourceDao.DeleteByProjectIdAndResourceIds(p.ProjectId, removedAssignments);
-                foreach (var item in p.AssignedProjectResources.ToList().Where(x => removedAssignments.Contains(x.ResourceId))) {
+                //for(int i = p.AssignedProjectResources.Count -1; i >= 0; i--) {
+                //  if(removedAssignments.Contains(p.AssignedProjectResources[i].ResourceId)) {
+                //    p.AssignedProjectResources.RemoveAt(i);
+                //  }
+                //}
+                foreach (var item in p.AssignedProjectResources
+                  .Where(x => removedAssignments.Contains(x.ResourceId))
+                  .ToList()) {
                   p.AssignedProjectResources.Remove(item);
                 }
