/**
  * Create new user
  * @param $res
  * @return null|UserModel2
  */
 public function create($res)
 {
     $user = new UserModel();
     $usernameWasAnEmail = $user->setUsername($res[UserRelaySchema::USERNAME]);
     if ($usernameWasAnEmail) {
         $user->setCreatedDate($res[UserRelaySchema::CREATED_ON]);
         $user->setName($res[UserRelaySchema::USERDISPLAYNAME]);
         $emailValid = $user->setEmail($res[UserRelaySchema::USER_EMAIL]);
         if (!$emailValid) {
             $this->LogError("Could not add " . $res[UserRelaySchema::USERNAME] . ". because userEmail did not look like an email. Ignored");
             return null;
         }
         $userNameOnDisk = str_replace('@', '', $res[UserRelaySchema::USERNAME]);
         $user->setUsernameOnDisk($userNameOnDisk);
         $org = explode('@', $res[UserRelaySchema::USERNAME]);
         if (isset($org[1])) {
             $user->setOrg($org[1]);
         }
         $user->setStatus(UserCreate::StatusNotSet);
         $user->setAffiliation("willBeSetIfFolderExistsAndUserSetAffiliationHaveDoneItsThing");
     } else {
         $this->LogError("Found user: "******", but could not create it" . ". Ignored");
         return null;
     }
     return $user;
 }
 public function insertUserToMongoDb(UserModel $user)
 {
     return $this->connection->save($user->jsonSerialize());
 }