Пример #1
0
        public RelatedProducts GetRelatedProducts(RelatedProductsRequest relatedProductsRequest)
        {
            HttpWebRequest  request         = CatalogRequestBuilder.ConstructRelatedProductsRequest(apiKey, relatedProductsRequest);
            RelatedProducts relatedProducts = ProcessBodylessRequest(request).ToObject <RelatedProducts>();

            return(relatedProducts);
        }
Пример #2
0
        public JsonResult Update(int productID, string products)
        {
            var jsonSuccessResult = new JsonSuccessResult();

            try
            {
                string[] arrProducts = products.Split(',');

                // حذف
                #region Delete All

                RelatedProducts.DeleteRelatedProducts(productID);

                #endregion Delete All

                // ثبت مجدد
                #region Add

                List <RelatedProduct> listItems = new List <RelatedProduct>();

                foreach (var item in arrProducts)
                {
                    if (!String.IsNullOrWhiteSpace(item))
                    {
                        RelatedProduct product = new RelatedProduct
                        {
                            ProductID  = productID,
                            RelationID = Int32.Parse(item),
                            LastUpdate = DateTime.Now,
                        };

                        listItems.Add(product);
                    }
                }

                RelatedProducts.Insert(listItems);

                #endregion Add

                jsonSuccessResult.Success = true;
            }
            catch (Exception ex)
            {
                jsonSuccessResult.Errors  = new string[] { ex.Message };
                jsonSuccessResult.Success = false;
            }

            return(new JsonResult()
            {
                Data = jsonSuccessResult
            });
        }
        public void TestGetAccessories()
        {
            RelatedProductsRequest relatedProductsRequest = new RelatedProductsRequest();

            relatedProductsRequest.Id      = "9200000010642550";
            relatedProductsRequest.DataSet = new EnumTypes.DataSetType[] {
                EnumTypes.DataSetType.ACCESSORIES,
            };

            RelatedProducts relatedProducts = client.GetRelatedProducts(relatedProductsRequest);

            Assert.IsNotNull(relatedProducts.Accessories);
            Assert.IsTrue(relatedProducts.Accessories.Count > 0);
        }
        public void TestGetProductFamilies()
        {
            RelatedProductsRequest relatedProductsRequest = new RelatedProductsRequest();

            relatedProductsRequest.Id      = "9200000009187246";
            relatedProductsRequest.DataSet = new EnumTypes.DataSetType[] {
                EnumTypes.DataSetType.PRODUCT_FAMILY
            };

            RelatedProducts relatedProducts = client.GetRelatedProducts(relatedProductsRequest);

            Assert.IsNotNull(relatedProducts.ProductFamilies);
            Assert.IsTrue(relatedProducts.ProductFamilies.Count > 0);
        }
        private void SetupProductLayoutWidgets(LayoutModel layoutModel, PageModel pageModel)
        {
            var breadcrumbs = new BreadCrumb
            {
                LayoutArea      = layoutModel.ProductLayout.LayoutAreas.First(x => x.AreaName == "Before Product Content"),
                Name            = "Breadcrumbs",
                IsRecursive     = true,
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 180
            };

            _widgetService.AddWidget(breadcrumbs);

            var relatedProducts = new RelatedProducts
            {
                LayoutArea      = layoutModel.ProductLayout.LayoutAreas.First(x => x.AreaName == "After Product Content"),
                Name            = "Related Products",
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Absolute,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(relatedProducts);

            var peopleAlsoBought = new PeopleWhoBoughtThisAlsoBought
            {
                LayoutArea      = layoutModel.ProductLayout.LayoutAreas.First(x => x.AreaName == "After Product Content"),
                Name            = "People who bought this also bought",
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Absolute,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(peopleAlsoBought);

            var otherCategories = new NotWhatYouWereLookingForWidget
            {
                LayoutArea      = layoutModel.ProductLayout.LayoutAreas.First(x => x.AreaName == "Below Product Price"),
                Name            = "Not what you were looking for?",
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Absolute,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(otherCategories);
        }
Пример #6
0
        private void BindRelatedProducts()
        {
            var relatedProducts = tree.SelectNodes(CurrentSiteName, "/Product-Bucket/%",
                                                   DocumentContext.CurrentDocumentCulture.CultureCode,
                                                   false, "Zurn.Product", string.Empty, "NodeOrder", -1, true, CurrentDocument.NodeGUID, RelatedProductsRelationshipName,
                                                   true).ToList();

            if (relatedProducts.Any())
            {
                RelatedProducts.DataSource = relatedProducts;
                RelatedProducts.DataBind();
            }
            else
            {
                RelatedProductSection.Visible = false;
            }
        }
Пример #7
0
        private void SetupProductLayoutWidgets(LayoutModel layoutModel, PageModel pageModel)
        {
            var breadcrumbs = new BreadCrumb
            {
                LayoutArea = layoutModel.ProductLayout.LayoutAreas.Single(x => x.AreaName == "Before Product Content"),
                Name = "Breadcrumbs",
                IsRecursive = true,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 180
            };
            _widgetService.AddWidget(breadcrumbs);

            var relatedProducts = new RelatedProducts
            {
                LayoutArea = layoutModel.ProductLayout.LayoutAreas.Single(x => x.AreaName == "After Product Content"),
                Name = "Related Products",
                Cache = true,
                CacheExpiryType = CacheExpiryType.Absolute,
                CacheLength = 1800
            };
            _widgetService.AddWidget(relatedProducts);

            var peopleAlsoBought = new PeopleWhoBoughtThisAlsoBought
            {
                LayoutArea = layoutModel.ProductLayout.LayoutAreas.Single(x => x.AreaName == "After Product Content"),
                Name = "People who bought this also bought",
                Cache = true,
                CacheExpiryType = CacheExpiryType.Absolute,
                CacheLength = 1800
            };
            _widgetService.AddWidget(peopleAlsoBought);

            var otherCategories = new NotWhatYouWereLookingForWidget
            {
                LayoutArea = layoutModel.ProductLayout.LayoutAreas.Single(x => x.AreaName == "Below Product Price"),
                Name = "Not what you were looking for?",
                Cache = true,
                CacheExpiryType = CacheExpiryType.Absolute,
                CacheLength = 1800
            };
            _widgetService.AddWidget(otherCategories);
        }
        /// <summary>
        /// If overriding don't forget to call base.Load() or make sure to
        /// assign the WrappedElement.
        /// </summary>
        /// <returns></returns>
        public override ILoadableComponent Load()
        {
            base.Load();
            GeneralInformation.Load();
            GiftCard.Load();
            DownloadableProduct.Load();
            RecurringProduct.Load();
            Rental.Load();
            Prices.Load();
            TierPrices.Load();
            AssociatedProducts.Load();
            Inventory.Load();
            Shipping.Load();
            Mapping.Load();
            AccessControlList.Load();
            RequireOtherProducts.Load();
            RelatedProducts.Load();

            return(this);
        }
Пример #9
0
        public JsonResult Get(int productID)
        {
            var jsonSuccessResult = new JsonSuccessResult();

            try
            {
                var list = RelatedProducts.Get(productID);

                jsonSuccessResult.Data    = list;
                jsonSuccessResult.Success = true;
            }
            catch (Exception ex)
            {
                jsonSuccessResult.Errors  = new string[] { ex.Message };
                jsonSuccessResult.Success = false;
            }

            return(new JsonResult()
            {
                Data = jsonSuccessResult
            });
        }
Пример #10
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Ean != null)
         {
             hashCode = hashCode * 59 + Ean.GetHashCode();
         }
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (Status != null)
         {
             hashCode = hashCode * 59 + Status.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Streams != null)
         {
             hashCode = hashCode * 59 + Streams.GetHashCode();
         }
         if (LevelSubjects != null)
         {
             hashCode = hashCode * 59 + LevelSubjects.GetHashCode();
         }
         if (Models != null)
         {
             hashCode = hashCode * 59 + Models.GetHashCode();
         }
         if (TrialAccessUrl != null)
         {
             hashCode = hashCode * 59 + TrialAccessUrl.GetHashCode();
         }
         if (DefaultAccessUrl != null)
         {
             hashCode = hashCode * 59 + DefaultAccessUrl.GetHashCode();
         }
         if (ShortDescription != null)
         {
             hashCode = hashCode * 59 + ShortDescription.GetHashCode();
         }
         if (LongDescription != null)
         {
             hashCode = hashCode * 59 + LongDescription.GetHashCode();
         }
         if (Media != null)
         {
             hashCode = hashCode * 59 + Media.GetHashCode();
         }
         if (RelatedProducts != null)
         {
             hashCode = hashCode * 59 + RelatedProducts.GetHashCode();
         }
         if (BundledProducts != null)
         {
             hashCode = hashCode * 59 + BundledProducts.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #11
0
        /// <summary>
        /// Returns true if Product instances are equal
        /// </summary>
        /// <param name="other">Instance of Product to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Product other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Ean == other.Ean ||
                     Ean != null &&
                     Ean.Equals(other.Ean)
                     ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Streams == other.Streams ||
                     Streams != null &&
                     Streams.SequenceEqual(other.Streams)
                 ) &&
                 (
                     LevelSubjects == other.LevelSubjects ||
                     LevelSubjects != null &&
                     LevelSubjects.SequenceEqual(other.LevelSubjects)
                 ) &&
                 (
                     Models == other.Models ||
                     Models != null &&
                     Models.SequenceEqual(other.Models)
                 ) &&
                 (
                     TrialAccessUrl == other.TrialAccessUrl ||
                     TrialAccessUrl != null &&
                     TrialAccessUrl.Equals(other.TrialAccessUrl)
                 ) &&
                 (
                     DefaultAccessUrl == other.DefaultAccessUrl ||
                     DefaultAccessUrl != null &&
                     DefaultAccessUrl.Equals(other.DefaultAccessUrl)
                 ) &&
                 (
                     ShortDescription == other.ShortDescription ||
                     ShortDescription != null &&
                     ShortDescription.Equals(other.ShortDescription)
                 ) &&
                 (
                     LongDescription == other.LongDescription ||
                     LongDescription != null &&
                     LongDescription.Equals(other.LongDescription)
                 ) &&
                 (
                     Media == other.Media ||
                     Media != null &&
                     Media.Equals(other.Media)
                 ) &&
                 (
                     RelatedProducts == other.RelatedProducts ||
                     RelatedProducts != null &&
                     RelatedProducts.SequenceEqual(other.RelatedProducts)
                 ) &&
                 (
                     BundledProducts == other.BundledProducts ||
                     BundledProducts != null &&
                     BundledProducts.SequenceEqual(other.BundledProducts)
                 ));
        }
Пример #12
0
        public List <CMSDDocumentDataSectionJob> HarvestJobs(Resource res)
        {
            _reloadJobs.Clear();
            foreach (var relatedProduct in RelatedProducts)
            {
                var relodedlist = new List <string>();
                foreach (var jobname in relatedProduct.Nodes.Where(t => t.Key.ResourceModel == this))
                {
                    relodedlist.Add(jobname.Value.Name);
                }
                _reloadJobs.Add(relatedProduct, relodedlist);
            }
            var list = new List <CMSDDocumentDataSectionJob>();

            foreach (Job declaredJob in Job)
            {
                var subjobs = new List <CMSDDocumentDataSectionJob>();
                int i       = 1;
                foreach (SubJob subjob in declaredJob.Subjobs)
                {
                    subjobs.Add(new CMSDDocumentDataSectionJob()
                    {
                        PlannedEffort =
                            new CMSDDocumentDataSectionJobPlannedEffort()
                        {
                            PartType =
                                RelatedProducts.Select(
                                    t => new CMSDDocumentDataSectionJobPlannedEffortPartType()
                            {
                                PartTypeIdentifier = t.ProductName
                            }).ToArray(),
                            ProcessingTime = new CMSDDocumentDataSectionJobPlannedEffortProcessingTime()
                            {
                                TimeUnit     = subjob.Distribution.ParameterConverter.UnitType.ToString(),
                                Distribution = subjob.Distribution.CMSDDistribution
                            }
                        },
                        Description = subjob.Description,
                        Identifier  = res.Identifier + declaredJob.Name + i++
                    });
                }
                list.AddRange(subjobs);


                list.Add(new CMSDDocumentDataSectionJob()
                {
                    SubJob = subjobs.Select(t => new CMSDDocumentDataSectionJobSubJob()
                    {
                        JobIdentifier = t.Identifier
                    }).ToArray(),
                    Identifier    = "BaseJob" + res.Identifier + declaredJob.Name,
                    PlannedEffort = new CMSDDocumentDataSectionJobPlannedEffort()
                    {
                        PartType =
                            RelatedProducts.Select(
                                t => new CMSDDocumentDataSectionJobPlannedEffortPartType()
                        {
                            PartTypeIdentifier = t.ProductName
                        }).ToArray(),
                        ResourcesRequired = new Resource[] { res },
                    }
                });
            }
            return(list);
        }