public static Customer addOrdersFromDB(Customer c) { Customer newCustomer = new Customer(c.getID()); List<Order> orders = orderDAO.retrieveOrders(c); for (Order o : orders) { newCustomer.addOrder(o); } return newCustomer; }
private void loadCustomers() { Customer a = new Customer("aaa", "900724-1111", "A-Gatan", "0702-AAA"); reg.addCustomer(a); Order gg = new Order(a, "11111"); a.addOrder(gg); reg.addOrder(gg); Customer b = new Customer("bbb", "900724-2222", "B-Gatan", "0702-BBB"); reg.addCustomer(b); Customer c = new Customer("ccc", "900724-3333", "C-Gatan", "0702-CCC"); reg.addCustomer(c); }
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()); } } }