store save function, adding a new entity and building add/replace for an existing