Implementing insert and update model code.