@Transactional @Override public Textbook update(Textbook object) { Textbook obj = textbookRepo.findOne(object.getId()); if (obj != null) { updateChapters(object.getChapters(), obj); updateSubject(object.getSubject(), obj); updateName(object.getName(), obj); textbookRepo.saveAndFlush(obj); } return obj; }
@Transactional @Override public Textbook delete(Long id) { Textbook obj = textbookRepo.findOne(id); if (obj != null) { Subject subject = obj.getSubject(); if (subject != null) { subject.removeTextbook(obj); subjectRepo.saveAndFlush(subject); } textbookRepo.delete(obj); textbookRepo.flush(); } return null; }
@Transactional @Override public int addEvaluation(Evaluation eval, Textbook textbook) { textbook.addEvaluation(eval); return evalRepo.updateTextbook(eval.getId(), textbook); }
@Transactional @Override public int updateChapters(int chapters, Textbook textbook) { textbook.setChapters(chapters); return textbookRepo.updateChapters(chapters, textbook.getId()); }
@Transactional @Override public int updateSubject(Subject subject, Textbook textbook) { textbook.setSubject(subject); return textbookRepo.updateSubject(textbook.getId(), subject); }
@Transactional @Override public int updateName(String name, Textbook object) { return textbookRepo.updateName(name, object.getId()); }