import org.codehaus.groovy.grails.plugins.springsecurity.Secured

class TaskPriorityController extends BaseController {
    
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only accept POST requests
    def allowedMethods = [delete:'POST', save:'POST', update:'POST']

    def list = {
        if(!params.max) params.max = 10
        [ taskPriorityInstanceList: TaskPriority.list( params ) ]
    }

    def show = {
        def taskPriorityInstance = TaskPriority.get( params.id )

        if(!taskPriorityInstance) {
            flash.message = "TaskPriority not found with id ${params.id}"
            redirect(action:list)
        }
        else { return [ taskPriorityInstance : taskPriorityInstance ] }
    }

    def delete = {
        def taskPriorityInstance = TaskPriority.get( params.id )
        if(taskPriorityInstance) {
            taskPriorityInstance.delete()
            flash.message = "TaskPriority ${params.id} deleted"
            redirect(action:list)
        }
        else {
            flash.message = "TaskPriority not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def taskPriorityInstance = TaskPriority.get( params.id )

        if(!taskPriorityInstance) {
            flash.message = "TaskPriority not found with id ${params.id}"
            redirect(action:list)
        }
        else {
            return [ taskPriorityInstance : taskPriorityInstance ]
        }
    }

    def update = {
        def taskPriorityInstance = TaskPriority.get( params.id )
        if(taskPriorityInstance) {
            taskPriorityInstance.properties = params
            if(!taskPriorityInstance.hasErrors() && taskPriorityInstance.save()) {
                flash.message = "TaskPriority ${params.id} updated"
                redirect(action:show,id:taskPriorityInstance.id)
            }
            else {
                render(view:'edit',model:[taskPriorityInstance:taskPriorityInstance])
            }
        }
        else {
            flash.message = "TaskPriority not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def taskPriorityInstance = new TaskPriority()
        taskPriorityInstance.properties = params
        return ['taskPriorityInstance':taskPriorityInstance]
    }

    def save = {
        def taskPriorityInstance = new TaskPriority(params)
        if(!taskPriorityInstance.hasErrors() && taskPriorityInstance.save()) {
            flash.message = "TaskPriority ${taskPriorityInstance.id} created"
            redirect(action:show,id:taskPriorityInstance.id)
        }
        else {
            render(view:'create',model:[taskPriorityInstance:taskPriorityInstance])
        }
    }
}
