public boolean bookTicket(User user, Ticket ticket) { if (!isBooked(ticket)) { Object[] params = { eventAuditoriumDAO.getId(ticket.getEventAuditorium()), user.getId(), ticket.getSeat() }; jdbcTemplateEmbedded.update(BOOK_TICKET, params); return true; } else { return false; } }
private boolean isBooked(Ticket ticket) { Object[] params = {eventAuditoriumDAO.getId(ticket.getEventAuditorium()), ticket.getSeat()}; return jdbcTemplateEmbedded.queryForObject(BOOKED_FOR_USER, params, Integer.class) > 0; }