public virtual object Clone() { var result = MemberwiseClone() as CatalogProduct; result.SeoInfos = SeoInfos?.Select(x => x.Clone()).OfType <SeoInfo>().ToList(); result.Images = Images?.Select(x => x.Clone()).OfType <Image>().ToList(); result.Assets = Assets?.Select(x => x.Clone()).OfType <Asset>().ToList(); result.Properties = Properties?.Select(x => x.Clone()).OfType <Property>().ToList(); result.Associations = Associations?.Select(x => x.Clone()).OfType <ProductAssociation>().ToList(); result.ReferencedAssociations = ReferencedAssociations?.Select(x => x.Clone()).OfType <ProductAssociation>().ToList(); result.Reviews = Reviews?.Select(x => x.Clone()).OfType <EditorialReview>().ToList(); result.Links = Links?.Select(x => x.Clone()).OfType <CategoryLink>().ToList(); result.Variations = Variations?.Select(x => x.Clone()).OfType <Variation>().ToList(); return(result); }
public virtual object Clone() { var result = MemberwiseClone() as CatalogProduct; // result.Catalog = (Catalog)Catalog?.Clone(); // Intentionally temporary disabled due to memory overhead // result.Category = (Category)Category?.Clone(); // Intentionally temporary disabled due to memory overhead result.SeoInfos = SeoInfos?.Select(x => x.Clone()).OfType <SeoInfo>().ToList(); result.Images = Images?.Select(x => x.Clone()).OfType <Image>().ToList(); result.Assets = Assets?.Select(x => x.Clone()).OfType <Asset>().ToList(); result.Properties = Properties?.Select(x => x.Clone()).OfType <Property>().ToList(); result.Associations = Associations?.Select(x => x.Clone()).OfType <ProductAssociation>().ToList(); result.ReferencedAssociations = ReferencedAssociations?.Select(x => x.Clone()).OfType <ProductAssociation>().ToList(); result.Reviews = Reviews?.Select(x => x.Clone()).OfType <EditorialReview>().ToList(); result.Links = Links?.Select(x => x.Clone()).OfType <CategoryLink>().ToList(); result.Variations = Variations?.Select(x => x.Clone()).OfType <Variation>().ToList(); // result.Outlines = Outlines?.Select(x => x.Clone()).OfType<Outline>().ToList(); // Intentionally temporary disabled due to memory overhead return(result); }
public virtual object Clone() { var result = base.MemberwiseClone() as CatalogProduct; if (SeoInfos != null) { result.SeoInfos = SeoInfos.Select(x => x.Clone()).OfType <SeoInfo>().ToList(); } if (Images != null) { result.Images = Images.Select(x => x.Clone()).OfType <Image>().ToList(); } if (Assets != null) { result.Assets = Assets.Select(x => x.Clone()).OfType <Asset>().ToList(); } if (Properties != null) { result.Properties = Properties.Select(x => x.Clone()).OfType <Property>().ToList(); } if (Associations != null) { result.Associations = Associations.Select(x => x.Clone()).OfType <ProductAssociation>().ToList(); } if (ReferencedAssociations != null) { result.ReferencedAssociations = ReferencedAssociations.Select(x => x.Clone()).OfType <ProductAssociation>().ToList(); } if (Reviews != null) { result.Reviews = Reviews.Select(x => x.Clone()).OfType <EditorialReview>().ToList(); } if (Links != null) { result.Links = Links.Select(x => x.Clone()).OfType <CategoryLink>().ToList(); } if (Variations != null) { result.Variations = Variations.Select(x => x.Clone()).OfType <Variation>().ToList(); } return(result); }
public virtual CatalogProduct ToModel(CatalogProduct product, bool convertChildrens = true, bool convertAssociations = true) { if (product == null) { throw new ArgumentNullException(nameof(product)); } product.Id = Id; product.CreatedDate = CreatedDate; product.CreatedBy = CreatedBy; product.ModifiedDate = ModifiedDate; product.ModifiedBy = ModifiedBy; product.CatalogId = CatalogId; product.CategoryId = CategoryId; product.Code = Code; product.DownloadExpiration = DownloadExpiration; product.DownloadType = DownloadType; product.EnableReview = EnableReview; product.EndDate = EndDate; product.Gtin = Gtin; product.HasUserAgreement = HasUserAgreement; product.Height = Height; product.IsActive = IsActive; product.IsBuyable = IsBuyable; product.Length = Length; product.MainProductId = ParentId; product.ManufacturerPartNumber = ManufacturerPartNumber; product.MaxNumberOfDownload = MaxNumberOfDownload; product.MaxQuantity = (int)MaxQuantity; product.MeasureUnit = MeasureUnit; product.MinQuantity = (int)MinQuantity; product.Name = Name; product.PackageType = PackageType; product.Priority = Priority; product.ProductType = ProductType; product.ShippingType = ShippingType; product.StartDate = StartDate; product.TaxType = TaxType; product.TrackInventory = TrackInventory; product.Vendor = Vendor; product.Weight = Weight; product.WeightUnit = WeightUnit; product.Width = Width; //Links product.Links = CategoryLinks.Select(x => x.ToModel(AbstractTypeFactory <CategoryLink> .TryCreateInstance())).ToList(); //Images product.Images = Images.OrderBy(x => x.SortOrder).Select(x => x.ToModel(AbstractTypeFactory <Image> .TryCreateInstance())).ToList(); //Assets product.Assets = Assets.OrderBy(x => x.CreatedDate).Select(x => x.ToModel(AbstractTypeFactory <Asset> .TryCreateInstance())).ToList(); // EditorialReviews product.Reviews = EditorialReviews.Select(x => x.ToModel(AbstractTypeFactory <EditorialReview> .TryCreateInstance())).ToList(); if (convertAssociations) { // Associations product.Associations = Associations.Select(x => x.ToModel(AbstractTypeFactory <ProductAssociation> .TryCreateInstance())).OrderBy(x => x.Priority).ToList(); product.ReferencedAssociations = ReferencedAssociations.Select(x => x.ToReferencedAssociationModel(AbstractTypeFactory <ProductAssociation> .TryCreateInstance())).OrderBy(x => x.Priority).ToList(); } //item property values product.PropertyValues = ItemPropertyValues .OrderBy(x => x.DictionaryItem?.SortOrder) .ThenBy(x => x.Name) .SelectMany(x => x.ToModel(AbstractTypeFactory <PropertyValue> .TryCreateInstance())).ToList(); if (Parent != null) { product.MainProduct = Parent.ToModel(AbstractTypeFactory <CatalogProduct> .TryCreateInstance(), false, convertAssociations); } if (convertChildrens) { // Variations product.Variations = new List <CatalogProduct>(); foreach (var variation in Childrens) { var productVariation = variation.ToModel(AbstractTypeFactory <CatalogProduct> .TryCreateInstance()); productVariation.MainProduct = product; productVariation.MainProductId = product.Id; product.Variations.Add(productVariation); } } return(product); }