create method

  1. @override
Domain create(
  1. Domain newObject
)
override

Create the domain Return the domain after been persisted, the returned domain have the properties assigned by the repo, like the new id.

Implementation

@override
Domain create(Domain newObject) {
  ///convert domain to entity to be compatible with External repo
  Entity entityToCreate = converter.toEntity(newObject);

  ///do the persist
  Entity entityCreated = externalRepo.create(entityToCreate); //do persist

  ///convert back the entity persisted to the domain
  newObject = converter.toDomain(entityCreated);

  return newObject;
}