public void updateUser(Long userId, String lastName, String firstName) { UserDTO currUser = getUser(userId); currUser = new UserDTO(userId, lastName, firstName, currUser.getEmail(), currUser.getRentalIds()); userService.saveOrUpdateUser(currUser); invalidateCache(); }
public void visitRentals(RentalVisitor visitor) { for (RentalDTO r : rentalService.getAllRentals()) { UserDTO user = userService.getUserById(r.getUserId()); MovieDTO movie = movieService.getMovieById(r.getMovieId()); visitor.visit( r.getId(), r.getRentalDays(), r.getRentalDate(), user.getLastName(), user.getFirstName(), movie.getTitle(), r.getRemainingDays(), r.getRentalFee()); } }
public void visitRentalsOfUser(Long userId, RentalVisitor visitor) { UserDTO user = userService.getUserById(userId); for (Long id : user.getRentalIds()) { RentalDTO r = rentalService.getRentalById(id); MovieDTO movie = movieService.getMovieById(r.getMovieId()); visitor.visit( r.getId(), r.getRentalDays(), r.getRentalDate(), user.getLastName(), user.getFirstName(), movie.getTitle(), r.getRemainingDays(), r.getRentalFee()); } }
public Long createUser(String lastName, String firstName) { UserDTO currUser = new UserDTO(null, lastName, firstName, null, null); Long id = userService.saveOrUpdateUser(currUser); invalidateCache(); return id; }
public void deleteUser(Long userId) { userService.deleteUser(userId); invalidateCache(); }
private UserDTO getUser(Long id) { if (user == null || !user.getId().equals(id)) { user = userService.getUserById(id); } return user; }
public void visitUsers(UserVisitor visitor) { for (UserDTO u : userService.getAllUsers()) { visitor.visit(u.getId(), u.getLastName(), u.getFirstName()); } }