String begindate = CalendarUtils.GetDateAsString(booking.getBeginDate());
String finishdate = CalendarUtils.GetDateAsString(booking.getFinishDate());
String code= booking.getStructure().getId() +booking.getName()+ booking.getSurname()+begindate+finishdate;
customerManager.add(booking.getCustomer());
for(Room room : booking.getRoomsToBooking()){
Booking bookingSingleRoom = new UnconfirmedBooking();
bookingSingleRoom.setAccomodation(booking.getAccomodation());
bookingSingleRoom.setBeginDate(booking.getBeginDate());
bookingSingleRoom.setCustomer(booking.getCustomer());
bookingSingleRoom.setFinishDate(booking.getFinishDate());
bookingSingleRoom.setStructure(booking.getStructure());
bookingSingleRoom.setRoom(room);
bookingSingleRoom.setCode(code);
bookingManager.add(bookingSingleRoom);
try {
ArrayList<Booking> bookings = (ArrayList<Booking>)bookingManager.searchByExample(bookingSingleRoom);
req.setAttribute("booking", bookings.get(0));
mail.sendMailHotel(bookingSingleRoom);
mail.sendMailCustomer(bookingSingleRoom);
} catch (MailException e) {
System.out.println(e.getMessage());
bookingManager.remove(bookingSingleRoom.getId());
throw e;
}
}