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