Пример #1
0
  public void bookRoom() {
    bookRoomResult = "";
    if (customerBean.getCurCust() == null) {
      //            Customer tmp = customerBean.getCurCust();
      bookRoomResult = "requiredlogin";
      return;
    }

    try {

      OrderRoom order = new OrderRoom();
      //    OrderDetail orderDetail = new OrderDetail();
      order.setOrderId(1);
      order.setCustID(curAccom.getCustId());
      order.setTotalPrice(new BigDecimal(curAccom.getPrice(), MathContext.DECIMAL64));
      order.setOrderDate(new Date());
      order.setStatus("Đã đặt phòng");
      order1Facade.create(order);
      bookRoomResult = "success";

    } catch (Exception ex) {
      printStackTrace();
      bookRoomResult = "false";
    }
  }
Пример #2
0
  public void displayAccomUpdate(Accommodation acc) {
    // curAccomUpdate = null;
    curAccomUpdate = new Accommodation();
    curAccomUpdate.setAccomName(acc.getAccomName());
    curAccomUpdate.setDescription(acc.getDescription());
    curAccomUpdate.setAddress(acc.getAddress());
    curAccomUpdate.setNoOfBed(acc.getNoOfBed());
    curAccomUpdate.setNoOfPersons(acc.getNoOfPersons());
    curAccomUpdate.setNoOfToilet(acc.getNoOfToilet());
    curAccomUpdate.setPrice(acc.getPrice());

    Gson gson = new Gson();
    String jsonRoom = gson.toJson(curAccomUpdate);

    UpdateRoomResult = jsonRoom;
  }
Пример #3
0
  public String displayRoomDetail(int id) {
    try {
      Accommodation accom = accommodationFacade.find(id);
      if (accom != null) {
        curAccom = new Accommodation();
        curAccom.setAccomName(accom.getAccomName());
        curAccom.setDescription(accom.getDescription());
        curAccom.setPrice(accom.getPrice());
        curAccom.setAccomId(id);
        curAccom.setNoOfBed(accom.getNoOfBed());
        curAccom.setNoOfPersons(accom.getNoOfPersons());
        curAccom.setNoOfToilet(accom.getNoOfToilet());
        curAccom.setCustId(customerFacade.find(1));

        List<Comments> commentsCount =
            commentsFacade.findCommentsByAccomId(
                id); // != null ? commentsFacade.findCommentsByAccomId(id).size() : 0;
        Gson gson = new Gson();
        RoomImage roomImage = gson.fromJson(accom.getImages(), RoomImage.class);
        // curAccom.setImages(accom.getImages());
        slider1 = roomImage.getSlider1();
        slider2 = roomImage.getSlider2();
        slider3 = roomImage.getSlider3();

        List<Rating> ratings = ratingFacade.findByAccRoomId(id);
        int sumRateScore = 0;
        for (Rating rate : ratings) {
          sumRateScore += rate.getScore();
        }
        displayRate = ratings.size() > 0 ? sumRateScore / ratings.size() : 0;
      }
    } catch (Exception ex) {
      printStackTrace();
    }
    return "roomdetail";
  }