Пример #1
0
 public static void addOrderToDB(Order o) {
   Customer customer = CustomerServiceImpl.getCustomer(o.getCustomerID());
   customer.setOrders(OrderServiceImpl.retrieveUnpaidOrders(customer));
   customer.addOrder(o);
   if (customer.getOrders().contains(o)) {
     orderDAO.addOrder(o);
     List<OrderItem> items = o.getItems();
     Inventory inventory = new Inventory(InventoryServiceImpl.getAllAvailableProductsInDB());
     for (OrderItem i : items) {
       Product product = ProductServiceImpl.getProduct(i.getItemSKUNumber());
       InventoryItem inventoryitem = InventoryServiceImpl.getInventoryItem(inventory, product);
       InventoryServiceImpl.deductFromInventory(inventory, inventoryitem, i.getQuantity());
     }
   }
 }
Пример #2
0
 public static void deleteOrderItem(Order order, int itemIndex) {
   List<OrderItem> items = order.getItems();
   OrderItem itemToBeRemoved = items.get(itemIndex);
   order.deleteItem(itemToBeRemoved);
 }