Example #1
0
 @Action
 public Response cancelBooking(String id) {
   Booking booking = Booking.find(id);
   booking.delete();
   flash.setSuccess("Booking cancelled for confirmation number " + id);
   return Hotels_.index();
 }
Example #2
0
  @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);
    }
  }
Example #3
0
 @View
 public void index() {
   String username = login.getUserName();
   List<Booking> bookings = Booking.findByUser(username);
   index.with().bookings(bookings).render();
 }