Index: trunk/grails-app/controllers/DepartmentController.groovy
===================================================================
--- trunk/grails-app/controllers/DepartmentController.groovy	(revision 162)
+++ trunk/grails-app/controllers/DepartmentController.groovy	(revision 162)
@@ -0,0 +1,99 @@
+import org.codehaus.groovy.grails.plugins.springsecurity.Secured
+
+class DepartmentController extends BaseAppAdminController {
+    
+    def index = { redirect(action:list,params:params) }
+
+    // the delete, save and update actions only accept POST requests
+    static allowedMethods = [delete:'POST', save:'POST', update:'POST']
+
+    def list = {
+        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
+        [ departmentInstanceList: Department.list( params ), departmentInstanceTotal: Department.count() ]
+    }
+
+    def show = {
+        def departmentInstance = Department.get( params.id )
+
+        if(!departmentInstance) {
+            flash.message = "Department not found with id ${params.id}"
+            redirect(action:list)
+        }
+        else { return [ departmentInstance : departmentInstance ] }
+    }
+
+    def delete = {
+        def departmentInstance = Department.get( params.id )
+        if(departmentInstance) {
+            try {
+                departmentInstance.delete(flush:true)
+                flash.message = "Department ${params.id} deleted"
+                redirect(action:list)
+            }
+            catch(org.springframework.dao.DataIntegrityViolationException e) {
+                flash.message = "Department ${params.id} could not be deleted"
+                redirect(action:show,id:params.id)
+            }
+        }
+        else {
+            flash.message = "Department not found with id ${params.id}"
+            redirect(action:list)
+        }
+    }
+
+    def edit = {
+        def departmentInstance = Department.get( params.id )
+
+        if(!departmentInstance) {
+            flash.message = "Department not found with id ${params.id}"
+            redirect(action:list)
+        }
+        else {
+            return [ departmentInstance : departmentInstance ]
+        }
+    }
+
+    def update = {
+        def departmentInstance = Department.get( params.id )
+        if(departmentInstance) {
+            if(params.version) {
+                def version = params.version.toLong()
+                if(departmentInstance.version > version) {
+                    
+                    departmentInstance.errors.rejectValue("version", "department.optimistic.locking.failure", "Another user has updated this Department while you were editing.")
+                    render(view:'edit',model:[departmentInstance:departmentInstance])
+                    return
+                }
+            }
+            departmentInstance.properties = params
+            if(!departmentInstance.hasErrors() && departmentInstance.save()) {
+                flash.message = "Department ${params.id} updated"
+                redirect(action:show,id:departmentInstance.id)
+            }
+            else {
+                render(view:'edit',model:[departmentInstance:departmentInstance])
+            }
+        }
+        else {
+            flash.message = "Department not found with id ${params.id}"
+            redirect(action:list)
+        }
+    }
+
+    def create = {
+        def departmentInstance = new Department()
+        departmentInstance.properties = params
+        return ['departmentInstance':departmentInstance]
+    }
+
+    def save = {
+        def departmentInstance = new Department(params)
+        if(!departmentInstance.hasErrors() && departmentInstance.save()) {
+            flash.message = "Department ${departmentInstance.id} created"
+            redirect(action:show,id:departmentInstance.id)
+        }
+        else {
+            render(view:'create',model:[departmentInstance:departmentInstance])
+        }
+    }
+}
Index: trunk/grails-app/controllers/SystemSectionController.groovy
===================================================================
--- trunk/grails-app/controllers/SystemSectionController.groovy	(revision 161)
+++ trunk/grails-app/controllers/SystemSectionController.groovy	(revision 162)
@@ -27,5 +27,5 @@
         if(systemSectionInstance) {
             try {
-                systemSectionInstance.delete()
+                systemSectionInstance.delete(flush:true)
                 flash.message = "SystemSection ${params.id} deleted"
                 redirect(action:list)
@@ -77,5 +77,5 @@
         else {
             flash.message = "SystemSection not found with id ${params.id}"
-            redirect(action:edit,id:params.id)
+            redirect(action:list)
         }
     }
Index: trunk/grails-app/controllers/SystemSectionDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/SystemSectionDetailedController.groovy	(revision 161)
+++ trunk/grails-app/controllers/SystemSectionDetailedController.groovy	(revision 162)
@@ -27,5 +27,5 @@
         if(systemSectionInstance) {
             try {
-                systemSectionInstance.delete()
+                systemSectionInstance.delete(flush:true)
                 flash.message = "SystemSection ${params.id} deleted"
                 redirect(action:list)
@@ -77,5 +77,5 @@
         else {
             flash.message = "SystemSection not found with id ${params.id}"
-            redirect(action:edit,id:params.id)
+            redirect(action:list)
         }
     }
