public void SetOrderBST(string customerName, List <Item> orderItems) { int orderId = customerName.GetHashCode(); BSTNode node = tree.Find(orderId); if (node == null) { Order order = new Order() { id = orderId, clientName = customerName, items = new List <Item>() }; tree.Insert(orderId, order); } else { orderId = node.GetData <Order>().clientName.GetHashCode(); node.SetData(new Order { id = orderId, clientName = customerName, items = orderItems }, orderId); } List <Order> nodes = new List <Order>(); tree.PreorderTraversal(nodes); OrderDataManager.UpdateOrders(nodes); }
public void SetItemBST(string itemName, int itemQuantity, float itemPrice, bool isOnSale, float salePercent) { int itemID = itemName.GetHashCode(); BSTNode node = tree.Find(itemID); if (node == null) { Item item = new Item() { id = itemID, name = itemName, price = itemPrice, quantity = itemQuantity, isOnSale = isOnSale, salePercent = salePercent }; tree.Insert(itemID, item); } else { itemID = node.GetData <Item>().name.GetHashCode(); node.SetData(new Item { id = itemID, name = node.GetData <Item>().name, price = itemPrice, quantity = itemQuantity, isOnSale = isOnSale, salePercent = salePercent }, itemID); } List <Item> nodes = new List <Item>(); tree.PreorderTraversal(nodes); StockDataManager.UpdateStock(nodes); }