@View public void confirmBooking( String id, String checkinDate, String checkoutDate, String beds, String smoking, String creditCard, String creditCardName, String creditCardExpiryMonth, String creditCardExpiryYear) { Map<String, Object> context = new HashMap<String, Object>(); Hotel hotel = Hotel.findById(id); context.put("total", 0); context.put("hotel", hotel); context.put("checkinDate", checkinDate); context.put("checkoutDate", checkoutDate); context.put("beds", beds); context.put("smoking", smoking); context.put("creditCard", creditCard); context.put("creditCardName", creditCardName); context.put("creditCardExpiryMonth", creditCardExpiryMonth); context.put("creditCardExpiryYear", creditCardExpiryYear); confirmBooking.render(context); }
@Action public Response processConfirmBooking( String confirm, String id, String checkinDate, String checkoutDate, String beds, String smoking, String creditCard, String creditCardName, String creditCardExpiryMonth, String creditCardExpiryYear) { Hotel hotel = Hotel.findById(id); User user = User.find(login.getUserName(), null); Booking booking = new Booking(hotel, user); booking.checkinDate = checkinDate; booking.checkoutDate = checkoutDate; booking.beds = Integer.parseInt(beds); booking.smoking = Boolean.valueOf(smoking); booking.creditCard = creditCard; booking.creditCardName = creditCardName; booking.creditCardExpiryMonth = Integer.parseInt(creditCardExpiryMonth); booking.creditCardExpiryYear = Integer.parseInt(creditCardExpiryYear); // validation.valid(booking); /* // Errors or revise if(validation.hasErrors() || params.get("revise") != null) { render("@book", hotel, booking); } // Confirm */ if (confirm != null) { booking.create(); flash.setSuccess( "Thank you, " + login.getUserName() + ", your confimation number for " + hotel.name + " is " + booking.id); return Hotels_.index(); } else { // Display booking return Hotels_.confirmBooking( id, checkinDate, checkoutDate, beds, smoking, creditCard, creditCardName, creditCardExpiryMonth, creditCardExpiryYear); } }
@Resource public void list(String search, String size, String page) { int _size = size != null ? Integer.parseInt(size) : 5; int _page = page != null ? Integer.parseInt(page) : 0; List<Hotel> hotels; Pattern pattern; if (search != null && search.trim().length() > 0) { pattern = Pattern.compile(".*" + Pattern.quote(search.trim()) + ".*", Pattern.CASE_INSENSITIVE); } else { pattern = Pattern.compile(".*"); } hotels = Hotel.find(pattern, pattern, _size, _page); list.with().hotels(hotels).page(_page).render(); }
@View public void show(String id) { Hotel hotel = Hotel.findById(id); show.with().hotel(hotel).render(); }
@View public void book(String id) { Hotel hotel = Hotel.findById(id); book.with().hotel(hotel).render(); }