Example #1
0
        /// <summary>
        ///
        /// This method will return the sought ProductField of this Product, if one is already present.
        /// If it is not present, it will create one by default and return it after inserting into
        /// our collection.
        ///
        /// <param name="poField">The Field representing the ProductField that we want to retrieve</param>
        /// <returns>The ProductField that we want to retrieve from this Product</returns>
        /// </summary>
        public WonkaProductField GetProductField(WonkaRefField poField)
        {
            WonkaProductField SoughtField = null;

            if (ProductFieldIndex.Keys.Contains(poField.FieldId))
            {
                SoughtField = ProductFieldIndex[poField.FieldId];
            }
            else if (WonkaRefEnvironment.GetInstance().DoesFieldExist(poField.FieldId))
            {
                ProductFieldIndex[poField.FieldId] = new WonkaProductField();

                SoughtField = ProductFieldIndex[poField.FieldId];

                SoughtField.ProductId = this.ProductId;
                SoughtField.FieldId   = poField.FieldId;
                SoughtField.LockCd    = "N";

                SoughtField.LastTouchedSourceId =
                    (this.OwnerSourceIds != null) && (this.OwnerSourceIds.Count > 0) ? this.OwnerSourceIds.ElementAt(0) : 0;
            }
            else
            {
                throw new Exception("ERROR!  WonkaProduct::getProductField(const WonkaRefField&) : " +
                                    "Requested field does not exist: (" + poField.FieldName + ").");
            }

            return(SoughtField);
        }
Example #2
0
        /// <summary>
        ///
        /// This method will update all contents of this Product with those of the provided one.
        ///
        /// <param name="poThatProduct">The Product from which we will copy our sought data</param>
        /// <param name="pbMergeFlag">Indicator of whether the provided data should completely overlay or merge with the contents of this Product</param>
        /// <returns>None</returns>
        /// </summary>
        public void Update(WonkaProduct ThatProduct, bool pbMergeFlag = true)
        {
            if (pbMergeFlag)
            {
                foreach (WonkaPrdGroup ThatPrdGroup in ThatProduct)
                {
                    this.Update(ThatPrdGroup, pbMergeFlag);
                }

                var iThatProductField = ThatProduct.ProductFieldIndex.GetEnumerator();
                while (iThatProductField.MoveNext())
                {
                    WonkaProductField ThatProductField = iThatProductField.Current.Value;

                    if (this.ProductFieldIndex.Keys.Contains(ThatProductField.FieldId))
                    {
                        this.ProductFieldIndex[ThatProductField.FieldId] = ThatProductField;
                    }
                }
            }
            else
            {
                ClearData();

                foreach (WonkaPrdGroup ThatPrdGroup in ThatProduct)
                {
                    this.Update(ThatPrdGroup, pbMergeFlag);
                }

                ClearFields();

                this.ProductFieldIndex = ThatProduct.ProductFieldIndex;
            }

            ClearErrors();
            this.ProductErrors = ThatProduct.ProductErrors;

            this.ResequenceGroups = ThatProduct.ResequenceGroups;

            this.IsAppendFasttrackEnabled = ThatProduct.IsAppendFasttrackEnabled;
            this.IsBatch = ThatProduct.IsBatch;
            this.IsGroupAppendEnabled  = ThatProduct.IsGroupAppendEnabled;
            this.IsGroupReplaceEnabled = ThatProduct.IsGroupReplaceEnabled;
            this.ProductId             = ThatProduct.ProductId;

            this.OwnerSourceIds = ThatProduct.OwnerSourceIds;
            this.TransactionId  = ThatProduct.TransactionId;
        }