merge a function of update and create

make a common function and change processing with an argument.