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