All pastes #2012753 Raw Edit

Something

public text v1 · immutable
#2012753 ·published 2010-12-07 11:29 UTC
rendered paste body
def updateUser(params) {
	log.debug "Called createUser with ${params}"
	def person = personDAO.findById(params.personId)
	person.firstName = params.firstName
	person.lastName = params.lastName
	person.telephone = params.telephone
	person.mobile = params.mobile
	person = personDAO.makePersistent(person)
	personDAO.flush()
	return person
}

/**
  * The definition for the updateUser method validations.
  */
def updateUser_constraints = {
	personId(nullable: false, minValue: 0, maxValue: Long.MAX_VALUE, type: Long)
	firstName(nullable:true, type: String)
	lastName(nullable:true, type: String)
	telephone(nullable: true, type: String)
	mobile(nullable: true, type: String)
}

============================>>

def updateUser(params) {
	log.debug "Called createUser with ${params}"
	def person = personDAO.findById(params.personId)
	person.firstName = params.firstName ?: person.firstName
	person.lastName = params.lastName ?: person.lastName
	person.telephone = params.telephone ?: person.telephone
	person.mobile = params.mobile ?: person.mobile
	person = personDAO.makePersistent(person)
	personDAO.flush()
	return person
}

/**
  * The definition for the updateUser method validations.
  */
def updateUser_constraints = {
	personId(nullable: false, minValue: 0, maxValue: Long.MAX_VALUE, type: Long)
	firstName(nullable: false, blank: false, type: String)
	lastName(nullable: false, blank: false, type: String)
	telephone(nullable: true, type: String)
	mobile(nullable: true, type: String)
}