[19] | 1 | class PersonGroupController { |
---|
| 2 | |
---|
| 3 | def index = { redirect(action:list,params:params) } |
---|
| 4 | |
---|
| 5 | // the delete, save and update actions only accept POST requests |
---|
| 6 | def allowedMethods = [delete:'POST', save:'POST', update:'POST'] |
---|
| 7 | |
---|
| 8 | def list = { |
---|
| 9 | if(!params.max) params.max = 10 |
---|
| 10 | [ personGroupInstanceList: PersonGroup.list( params ) ] |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | def show = { |
---|
| 14 | def personGroupInstance = PersonGroup.get( params.id ) |
---|
| 15 | |
---|
| 16 | if(!personGroupInstance) { |
---|
| 17 | flash.message = "PersonGroup not found with id ${params.id}" |
---|
| 18 | redirect(action:list) |
---|
| 19 | } |
---|
| 20 | else { return [ personGroupInstance : personGroupInstance ] } |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | def delete = { |
---|
| 24 | def personGroupInstance = PersonGroup.get( params.id ) |
---|
| 25 | if(personGroupInstance) { |
---|
| 26 | personGroupInstance.delete() |
---|
| 27 | flash.message = "PersonGroup ${params.id} deleted" |
---|
| 28 | redirect(action:list) |
---|
| 29 | } |
---|
| 30 | else { |
---|
| 31 | flash.message = "PersonGroup not found with id ${params.id}" |
---|
| 32 | redirect(action:list) |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | def edit = { |
---|
| 37 | def personGroupInstance = PersonGroup.get( params.id ) |
---|
| 38 | |
---|
| 39 | if(!personGroupInstance) { |
---|
| 40 | flash.message = "PersonGroup not found with id ${params.id}" |
---|
| 41 | redirect(action:list) |
---|
| 42 | } |
---|
| 43 | else { |
---|
| 44 | return [ personGroupInstance : personGroupInstance ] |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | def update = { |
---|
| 49 | def personGroupInstance = PersonGroup.get( params.id ) |
---|
| 50 | if(personGroupInstance) { |
---|
| 51 | personGroupInstance.properties = params |
---|
| 52 | if(!personGroupInstance.hasErrors() && personGroupInstance.save()) { |
---|
| 53 | flash.message = "PersonGroup ${params.id} updated" |
---|
| 54 | redirect(action:show,id:personGroupInstance.id) |
---|
| 55 | } |
---|
| 56 | else { |
---|
| 57 | render(view:'edit',model:[personGroupInstance:personGroupInstance]) |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | else { |
---|
| 61 | flash.message = "PersonGroup not found with id ${params.id}" |
---|
| 62 | redirect(action:edit,id:params.id) |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | def create = { |
---|
| 67 | def personGroupInstance = new PersonGroup() |
---|
| 68 | personGroupInstance.properties = params |
---|
| 69 | return ['personGroupInstance':personGroupInstance] |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | def save = { |
---|
| 73 | def personGroupInstance = new PersonGroup(params) |
---|
| 74 | if(!personGroupInstance.hasErrors() && personGroupInstance.save()) { |
---|
| 75 | flash.message = "PersonGroup ${personGroupInstance.id} created" |
---|
| 76 | redirect(action:show,id:personGroupInstance.id) |
---|
| 77 | } |
---|
| 78 | else { |
---|
| 79 | render(view:'create',model:[personGroupInstance:personGroupInstance]) |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | } |
---|