public Boolean FinalizeVendorOrder(VendorOrder order)
        {
            if (order == null)
            {
                throw new ApplicationException("VendorOrder cannot be null");
            }
            if (order.LineItems == null)
            {
                throw new ApplicationException("VendorOrder cannot have zero line items");
            }
            var oldOrder = new VendorOrder(order.Id, order.VendorID);

            oldOrder.Finalized         = order.Finalized;
            oldOrder.NumberOfShipments = order.NumberOfShipments;
            order.Finalized            = true;
            foreach (VendorOrderLineItem item in order.LineItems)
            {
                prodMan.AddToAvailable(item.QtyReceived, item.ProductID);
                prodMan.AddToOnHand(item.QtyDamaged + item.QtyReceived, item.ProductID);
                prodMan.RemoveFromOnOrder(item.QtyReceived + item.QtyDamaged, item.ProductID);
            }
            var result = VendorOrderDAL.Update(oldOrder, order, _connection);

            return(result);
        }
        public bool UpdateShipmentsReceived(VendorOrder order, int qtyReceived)
        {
            if (order == null)
            {
                throw new ApplicationException("VendorOrder cannot be null");
            }
            if (qtyReceived + order.NumberOfShipments < 0)
            {
                throw new ApplicationException("Total quantity of shipments received cannot be negative");
            }
            var oldOrder = order;

            order.NumberOfShipments += qtyReceived;
            var result = VendorOrderDAL.Update(oldOrder, order, _connection);

            return(result);
        }