@Override @Transactional public Boolean delete(Integer id) { List<OrderReader> list = readerDAO.findOwerReaders(id); if (list.isEmpty()) { readerDAO.delete(id); return true; } else return false; }
@Override @Transactional public Boolean save(Reader reader) { Reader r = readerDAO.findReaderByFullName(reader.getName(), reader.getSurname(), reader.getBirth()); if (r == null) { readerDAO.save(reader); return false; } else { return true; } }
@Override @Transactional public void update(Reader reader, Integer id) { Reader reader1 = findById(id); reader1.setPhone(reader.getPhone()); reader1.setName(reader.getName()); reader1.setSurname(reader.getSurname()); reader1.setBirth(reader.getBirth()); reader1.setAdress(reader.getAdress()); readerDAO.update(reader1); }
@Override @Transactional public List<Reader> findAll() { return readerDAO.findAll(); }
@Override @Transactional public Reader findById(Integer id) { return readerDAO.find(id); }