Index: trunk/grails-app/services/AssignedGroupService.groovy
===================================================================
--- trunk/grails-app/services/AssignedGroupService.groovy	(revision 247)
+++ trunk/grails-app/services/AssignedGroupService.groovy	(revision 251)
@@ -1,4 +1,7 @@
 class AssignedGroupService {
+
     boolean transactional = false
+
+    def personService
 
     def list(params) {
@@ -37,24 +40,37 @@
 
     def delete(params) {
-        def result = [:]
-        def fail = { Map m ->
-            result.error = [ code: m.code, args: ["AssignedGroup", params.id] ]
-            return result
-        }
+        AssignedGroup.withTransaction { status ->
+            def result = [:]
 
-        result.assignedGroupInstance = AssignedGroup.get(params.id)
+            def fail = { Map m ->
+                status.setRollbackOnly()
+                if(result.assignedGroupInstance && m.field)
+                    result.assignedGroupInstance.errors.rejectValue(m.field, m.code)
+                result.error = [ code: m.code, args: ["AssignedGroup", params.id] ]
+                return result
+            }
 
-        if(!result.assignedGroupInstance)
-            return fail(code:"default.not.found")
+            result.assignedGroupInstance = AssignedGroup.get(params.id)
 
-        try {
-            result.assignedGroupInstance.delete(flush:true)
-            return result //Success.
-        }
-        catch(org.springframework.dao.DataIntegrityViolationException e) {
-            return fail(code:"default.delete.failure")
-        }
+            if(!result.assignedGroupInstance)
+                return fail(code:"default.not.found")
 
-    }
+            def taskModification = new TaskModification(person: personService.currentUser,
+                                                    taskModificationType: TaskModificationType.get(10),
+                                                    task: result.assignedGroupInstance.task)
+
+            if(!taskModification.save())
+                return fail(field:"taskModifications", code:"task.modifications.failedToSave")
+
+            try {
+                result.assignedGroupInstance.delete(flush:true)
+                return result //Success.
+            }
+            catch(org.springframework.dao.DataIntegrityViolationException e) {
+                return fail(code:"default.delete.failure")
+            }
+
+        } //end withTransaction
+    } // end delete()
 
     def edit(params) {
@@ -102,4 +118,11 @@
                 return fail(code:"default.update.failure")
 
+            def taskModification = new TaskModification(person: personService.currentUser,
+                                                    taskModificationType: TaskModificationType.get(10),
+                                                    task: result.assignedGroupInstance.task)
+
+            if(!taskModification.save())
+                return fail(field:"taskModifications", code:"task.modifications.failedToSave")
+
             // Success.
             return result
@@ -126,20 +149,34 @@
 
     def save(params) {
-        def result = [:]
-        def fail = { Map m ->
-            if(result.assignedGroupInstance && m.field)
-                result.assignedGroupInstance.errors.rejectValue(m.field, m.code)
-            result.error = [ code: m.code, args: ["AssignedGroup", params.id] ]
+        AssignedGroup.withTransaction { status ->
+            def result = [:]
+
+            def fail = { Map m ->
+                if(result.assignedGroupInstance && m.field)
+                    result.assignedGroupInstance.errors.rejectValue(m.field, m.code)
+                result.error = [ code: m.code, args: ["AssignedGroup", params.id] ]
+                return result
+            }
+
+            result.assignedGroupInstance = new AssignedGroup(params)
+
+            if(result.assignedGroupInstance.hasErrors() || !result.assignedGroupInstance.save())
+                return fail(code:"default.create.failure")
+
+            // Record a taskModification for every one except "system".
+            if(personService.currentUser.id != 1) {
+                def taskModification = new TaskModification(person: personService.currentUser,
+                                                        taskModificationType: TaskModificationType.get(10),
+                                                        task: result.assignedGroupInstance.task)
+
+                if(!taskModification.save())
+                    return fail(field:"taskModifications", code:"task.modifications.failedToSave")
+            }
+
+            // success
             return result
-        }
 
-        result.assignedGroupInstance = new AssignedGroup(params)
-
-        if(result.assignedGroupInstance.hasErrors() || !result.assignedGroupInstance.save(flush: true))
-            return fail(code:"default.create.failure")
-
-        // success
-        return result
-    }
+        } //end withTransaction
+    } // end save()
 
 } // end class
