public boolean edit(int id, AccountEditViewModel accountEditViewModel) { boolean result = false; try { Accounts account = super.find(id); if (!accountEditViewModel.getRole().equals(Accounts.AccountRole.NOTSET)) { account.setRole(accountEditViewModel.getRole()); } account.setUpdated(new Timestamp((new Date()).getTime())); account.setFirstName(accountEditViewModel.getFirstName()); account.setLastName(accountEditViewModel.getLastName()); if (accountEditViewModel.getEmail() != null && accountEditViewModel.getEmail().length() > 0) { account.setEmail(accountEditViewModel.getEmail()); } account.setPhoneNumber(accountEditViewModel.getPhoneNumber()); account.setStreetName(accountEditViewModel.getStreetName()); account.setStreetNumber(accountEditViewModel.getStreetNumber()); account.setCity(accountEditViewModel.getCity()); account.setTags(accountEditViewModel.getTags()); super.edit(account); result = true; } catch (Exception e) { logger.warn(e.getMessage()); } return result; }
public boolean remove(int id) { boolean result = false; try { Accounts account = super.find(id); super.remove(account); result = true; } catch (Exception e) { logger.warn(e.getMessage()); } return result; }
public boolean changePassword(int id, AccountPasswordViewModel pswdViewModel) { boolean result = false; try { Accounts account = super.find(id); if (account.getPassword().equals(pswdViewModel.getOldPassword()) && pswdViewModel.getNewPassword() != null && pswdViewModel.getNewPassword().length() > 0) { account.setPassword(pswdViewModel.getNewPassword()); super.edit(account); result = true; } } catch (Exception e) { logger.warn(e.getMessage()); } return result; }