Index: trunk/grails-app/services/AssignedPersonService.groovy
===================================================================
--- trunk/grails-app/services/AssignedPersonService.groovy	(revision 251)
+++ trunk/grails-app/services/AssignedPersonService.groovy	(revision 255)
@@ -4,38 +4,4 @@
 
     def personService
-
-    def list(params) {
-        def result = [:]
-        def fail = { Map m ->
-            result.error = [ code: m.code, args: ["AssignedPerson"] ]
-            return result
-        }
-
-        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
-        result.assignedPersonInstanceList = AssignedPerson.list(params)
-        result.assignedPersonInstanceTotal = AssignedPerson.count()
-
-        if(!result.assignedPersonInstanceList || !result.assignedPersonInstanceTotal)
-            return fail(code:"default.list.failure")
-
-        // Success.
-        return result
-    }
-
-    def show(params) {
-        def result = [:]
-        def fail = { Map m ->
-            result.error = [ code: m.code, args: ["AssignedPerson", params.id] ]
-            return result
-        }
-
-        result.assignedPersonInstance = AssignedPerson.get(params.id)
-
-        if(!result.assignedPersonInstance)
-            return fail(code:"default.not.found")
-
-        // Success.
-        return result
-    }
 
     def delete(params) {
@@ -86,4 +52,7 @@
             return fail(code:"default.not.found")
 
+        result.person = result.assignedPersonInstance.person
+        result.groupsForPerson = result.person.personGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
+
         // Success.
         return result
@@ -101,4 +70,12 @@
                 return result
             }
+
+            result.person = Person.get(params.person.id)
+
+            // Prevent a null property reference.
+            if(!result.person)
+                return fail(code:"person.not.found")
+
+            result.groupsForPerson = result.person.personGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
 
             result.assignedPersonInstance = AssignedPerson.get(params.id)
@@ -144,5 +121,8 @@
         result.assignedPersonInstance.properties = params
 
-        // success
+        result.person = Person.list().sort { p1, p2 -> p1.firstName.compareToIgnoreCase(p2.firstName) }[0] // Get the first result.
+        result.groupsForPerson = result.person.personGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
+
+        // Success.
         return result
     }
@@ -153,4 +133,5 @@
 
             def fail = { Map m ->
+                status.setRollbackOnly()
                 if(result.assignedPersonInstance && m.field)
                     result.assignedPersonInstance.errors.rejectValue(m.field, m.code)
@@ -159,5 +140,14 @@
             }
 
-            result.assignedPersonInstance = new AssignedPerson(params)
+            result.person = Person.get(params.person.id)
+
+            // Prevent a null property reference.
+            if(!result.person)
+                return fail(code:"person.not.found")
+
+            result.groupsForPerson = result.person.personGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
+
+            result.assignedPersonInstance = new AssignedPerson()
+            result.assignedPersonInstance.properties = params
 
             if(result.assignedPersonInstance.hasErrors() || !result.assignedPersonInstance.save())
@@ -180,3 +170,22 @@
     } // end save()
 
+    def groupsForPerson(params) {
+        def result = [:]
+
+        def fail = { Map m ->
+            result.error = [ code: m.code, args: ["Person", params.person?.id] ]
+            return result
+        }
+
+        result.person = Person.get(params.person?.id)
+
+        if(!result.person)
+            return fail(code:"default.not.found")
+
+        result.groupsForPerson = result.person.personGroups.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
+
+        // Success.
+        return result
+    }
+
 } // end class
