Exemple #1
0
 public static void deleteBookOrder(Long id) {
   BookOrder order = BookOrder.findById(id);
   System.out.println(
       "Admin::deleteBookOrder()::got order:" + order.getId() + " of status:" + order.status);
   order.delete();
   System.out.println("Admin::deleteBookOrder()::deleted order");
   Admin.customerOrders();
 }
Exemple #2
0
  public static void editBookOrder(Long id, @Required String status) {
    System.out.println("editBookOrder()::you selected status=" + status);
    boolean statuschanged = false;
    Status newStatus = null;
    BookOrder order = BookOrder.findById(id);
    System.out.println("editBookOrder()::got order:" + order.id + " of status:" + order.status);
    if (status != null && status.trim().length() > 0 && !order.status.equals(Status.DELIVERED)) {
      try {
        // try to create new status
        newStatus = Status.valueOf(status);
      } catch (IllegalArgumentException iae) {
        System.out.println(
            "editBookOrder()::invalid Order Status" + status + "=" + status.length());
        validation.addError("orderstatus", "Enter a valid Order Status");
        params.flash();
        validation.keep();
        showEditBookOrderForm(id);
      }

      if (!order.status.equals(status)) {
        statuschanged = true;
      }
      Date now = new Date();
      if (statuschanged) {
        // parse string to enum and set new status
        order.status = newStatus;
        order.orderDate = now;
        order.save();
        // send email to client
        // EmailUtils.sendEmail(order.customer, order,statuschanged);
        System.out.println("editBookOrder()::new orderstatus set");
      }
      Admin.customerOrders();

    } else {
      System.out.println("editBookOrder()::nothing");
      showEditBookOrderForm(id);
    }
  }