public void apply() throws IOException {
   try {
     if (addLoginUser) {
       if (!password.equals(passwordConfirm)) {
         sessionManager.addGlobalMessageFatal("Password is not equal to Confirm Password.", null);
         throw new ValidatorException(
             new FacesMessage(
                 FacesMessage.SEVERITY_FATAL,
                 "Password and Confirm Password are not equal.",
                 null));
       }
     }
     if (hasPhoto) {
       String photoName = editWorkInfo.getId() + FileUtil.getSuffix(tmpName);
       FileUtil.renameFile(sessionManager.getPhotoPath(), tmpName, photoName);
       editWorkInfo.setPhotoName(photoName);
     }
     editWorkInfo.setName(firstName + " " + lastName);
     workInfoService.add(editWorkInfo);
     if (addLoginUser) {
       editUser.setPassword(PasswordHash.makePasswordHash(password));
       editUser.getEmployee().setId(editWorkInfo.getId());
       userService.add(editUser);
     }
     clear();
   } catch (IOException e) {
     logger.error("Employee Date update error.", e);
     sessionManager.addGlobalMessageFatal("Employee Data update error.", null);
     throw e;
   }
 }
 private void addEmployees(ArrayList<WorkInfoDto> list) throws IOException {
   for (WorkInfoDto e : list) {
     workInfoService.add(e);
   }
 }