Skip to content

Commit

Permalink
Close #9
Browse files Browse the repository at this point in the history
  • Loading branch information
migrosdata committed Apr 29, 2019
1 parent 9968629 commit 88aa536
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,18 @@ public void deleteCourse(Long programId, Long courseId) throws CourseException {

public Course updateCourse(Long programId, Long courseId, Course newCourse)
throws CourseException {
//TODO: course not saved
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
Course course = getCourseById(programId, courseId);
Course course = entityManager.find(Course.class, courseId);
if (course == null) {
logger.error( "course with id " + courseId +" not found");
logger.error(" course with id " + course.getId() + " not found");
throw new CourseException(" course not found");
}
course.setQuarter(newCourse.getQuarter());
course.setYear(newCourse.getYear());
course.setMaxNumberOfParticipants(newCourse.getMaxNumberOfParticipants());
entityManager.getTransaction().commit();
logger.info(" course" + course.getId() + " upodated");
logger.info(" course" + course.getId() + " updated");
return course;
}

Expand Down Expand Up @@ -375,7 +374,7 @@ public List<Session> addSessions(Long programId, Long courseId, List<Session> se

Course course = entityManager.find(Course.class, courseId);
if (course == null) {
logger.error(" course with id " + program.getId() + " not found");
logger.error(" course with id " + course.getId() + " not found");
throw new CourseException(" course not found");
}
for (Session session : sessions) {
Expand Down

0 comments on commit 88aa536

Please sign in to comment.