In order to write a model you need to have configured an action within the model capable of performing a write action. For more information on creating actions, see the section within this chapter titled "State Model".
Below is a simple example of writing a model to the database using an action.
Once you create the object you want to write, and have identified an action to use, create an instance of ModelDataService. ModelDataService is responsible for all persistence operations in the SDK. Its write method takes two arguments. The first is a ModelList, which is a type-safe collection of whatever type of model you wish to write. You can write many models in one pass by adding them each to the model list. The second parameter is the Platform User Context for the current user. This is available in any of the classes where you would want to programmatically manipulate models such as within a REST resource class, a workflow, an IXM Engine, etc.
The write operation returns a second model list, again type-safe to the type you are working with. If any of the write actions from the model list failed, they are returned in this returned model list with error codes attached.