示例#1
0
        // Comparison Operators
        //public static bool operator ==(ParentProduct a, ParentProduct b)
        //{
        //    if (ReferenceEquals(a, b))
        //        return true;
        //    return a.Equals(b);
        //}

        //public static bool operator !=(ParentProduct a, ParentProduct b)
        //{
        //    return !(a == b);
        //}

        //public static bool operator ==(ParentProduct a, string b)
        //{
        //    return a.Equals(b);
        //}

        //public static bool operator !=(ParentProduct a, string b)
        //{
        //    return !(a == b);
        //}

        //public static bool operator ==(string a, ParentProduct b)
        //{
        //    return (b == a);
        //}

        //public static bool operator !=(string a, ParentProduct b)
        //{
        //    return !(a == b);
        //}

        // ********************
        // * Member Functions *
        // ********************

        // Update Function
        public bool UpdateData(ParentProduct update)
        {
            if (this == update)
            {
                UpdateData(update);

                MetaTagKeywords = update.MetaTagKeywords;
                Description     = update.Description;
                OnHomePage      = update.OnHomePage;

                // Update Child Products with new data
                foreach (var child in update.ChildProducts)
                {
                    var index = ChildProducts.FindIndex(x => x == child);
                    if (index == -1)
                    {
                        ChildProducts.Add(child);
                    }
                    else
                    {
                        ChildProducts[index].UpdateData(child);
                    }
                }

                return(true);
            }

            return(false);
        }
示例#2
0
 protected void AddProduct(Product product)
 {
     ChildProducts.Add(product);
 }