Ejemplo n.º 1
0
        // ------------------------------------------------
        public BinProduct Remove(BinProduct bpProduct)
        {
            BinProduct retVal = new BinProduct()
            {
                UnitCount = 0,
                UnitRetail = bpProduct.UnitRetail,
                ProductID = bpProduct.ProductID
            };

            foreach(BinProduct prod in BinProducts)
            {
                if(prod == bpProduct)
                {
                    // -------------------------------
                    // If we have more than requested,
                    // just get the units requested.

                    if(prod.UnitCount > bpProduct.UnitCount)
                    {
                        prod.UnitCount -= bpProduct.UnitCount;
                        retVal.UnitCount += bpProduct.UnitCount;
                    }
                    else
                    {
                        // ---------------------------------
                        // If there are fewer than requested
                        // or exactly the nuimber requested,
                        // take all units available.

                        BinProducts.Remove(prod);
                        retVal.UnitCount = prod.UnitCount;
                    }

                    break;
                }
            }

            return retVal;
        }
Ejemplo n.º 2
0
        // ------------------------------------------------
        public void Add(BinProduct bpProduct)
        {
            if(BinProducts.Count + bpProduct.UnitCount > Capacity)
            {
                string msg = string.Format("Addition exceeds capacity.{0}BinID: {1}{0}BinProduct: {2}",
                                           Environment.NewLine,
                                           ID,
                                           bpProduct.ToString());

                throw new OverflowException(msg);
            }
            else
            {
                BinProducts.Add(bpProduct);
            }
        }