Example #1
0
        public virtual void Patch(ItemEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.IsBuyable      = IsBuyable;
            target.IsActive       = IsActive;
            target.TrackInventory = TrackInventory;
            target.MinQuantity    = MinQuantity;
            target.MaxQuantity    = MaxQuantity;
            target.EnableReview   = EnableReview;

            target.CatalogId              = CatalogId;
            target.CategoryId             = CategoryId;
            target.Name                   = Name;
            target.Code                   = Code;
            target.ManufacturerPartNumber = ManufacturerPartNumber;
            target.Gtin                   = Gtin;
            target.ProductType            = ProductType;
            target.MaxNumberOfDownload    = MaxNumberOfDownload;
            target.DownloadType           = DownloadType;
            target.HasUserAgreement       = HasUserAgreement;
            target.DownloadExpiration     = DownloadExpiration;
            target.Vendor                 = Vendor;
            target.TaxType                = TaxType;
            target.WeightUnit             = WeightUnit;
            target.Weight                 = Weight;
            target.MeasureUnit            = MeasureUnit;
            target.PackageType            = PackageType;
            target.Height                 = Height;
            target.Length                 = Length;
            target.Width                  = Width;
            target.ShippingType           = ShippingType;
            target.Priority               = Priority;
            target.ParentId               = ParentId;
            target.StartDate              = StartDate;
            target.EndDate                = EndDate;

            #region Assets
            if (!Assets.IsNullCollection())
            {
                Assets.Patch(target.Assets, (sourceAsset, targetAsset) => sourceAsset.Patch(targetAsset));
            }
            #endregion

            #region Images
            if (!Images.IsNullCollection())
            {
                Images.Patch(target.Images, (sourceImage, targetImage) => sourceImage.Patch(targetImage));
            }
            #endregion

            #region ItemPropertyValues
            if (!ItemPropertyValues.IsNullCollection())
            {
                ItemPropertyValues.Patch(target.ItemPropertyValues, (sourcePropValue, targetPropValue) => sourcePropValue.Patch(targetPropValue));
            }
            #endregion

            #region Links
            if (!CategoryLinks.IsNullCollection())
            {
                CategoryLinks.Patch(target.CategoryLinks, new CategoryItemRelationComparer(),
                                    (sourcePropValue, targetPropValue) => sourcePropValue.Patch(targetPropValue));
            }
            #endregion

            #region EditorialReviews
            if (!EditorialReviews.IsNullCollection())
            {
                EditorialReviews.Patch(target.EditorialReviews, (sourcePropValue, targetPropValue) => sourcePropValue.Patch(targetPropValue));
            }
            #endregion

            #region Association
            if (!Associations.IsNullCollection())
            {
                var associationComparer = AnonymousComparer.Create((AssociationEntity x) => x.AssociationType + ":" + x.AssociatedItemId + ":" + x.AssociatedCategoryId);
                Associations.Patch(target.Associations, associationComparer,
                                   (sourceAssociation, targetAssociation) => sourceAssociation.Patch(targetAssociation));
            }
            #endregion
        }