protected void UpdateAttributeLocales(SpecificationAttribute specificationAttribute, SpecificationAttributeModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(specificationAttribute,
                                                        x => x.Name,
                                                        localized.Name,
                                                        localized.LanguageId);
     }
 }
        public void Can_save_and_load_specificationAttribute()
        {
            var specificationAttribute = new SpecificationAttribute
            {
                Name = "Name 1",
                DisplayOrder = 1,
            };

            var fromDb = SaveAndLoadEntity(specificationAttribute);
            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("Name 1");
            fromDb.DisplayOrder.ShouldEqual(1);
        }
        /// <summary>
        /// Deletes a specification attribute
        /// </summary>
        /// <param name="specificationAttribute">The specification attribute</param>
        public virtual void DeleteSpecificationAttribute(SpecificationAttribute specificationAttribute)
        {
            if (specificationAttribute == null)
                throw new ArgumentNullException("specificationAttribute");

            _specificationAttributeRepository.Delete(specificationAttribute);

            _cacheManager.RemoveByPattern(SPECIFICATIONATTRIBUTE_PATTERN_KEY);
            _cacheManager.RemoveByPattern(SPECIFICATIONATTRIBUTEOPTION_PATTERN_KEY);
            _cacheManager.RemoveByPattern(PRODUCTSPECIFICATIONATTRIBUTE_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityDeleted(specificationAttribute);
        }
Exemplo n.º 4
0
        public SpecificationAttribute Clone()
        {
            var newOb = new SpecificationAttribute()
            {
                Id           = this.Id,
                Name         = this.Name,
                DisplayOrder = this.DisplayOrder,
                SpecificationAttributeOptions = new Collection <SpecificationAttributeOption>()
            };

            foreach (var specificationAttributeOption in SpecificationAttributeOptions.ToList())
            {
                newOb.SpecificationAttributeOptions.Add(specificationAttributeOption.Clone());
            }


            return(newOb);
        }
        public void Can_save_and_load_specificationAttribute_with_specificationAttributeOptions()
        {
            var specificationAttribute = new SpecificationAttribute
            {
                Name = "Name 1",
                DisplayOrder = 1
            };
            specificationAttribute.SpecificationAttributeOptions.Add
                (
                    new SpecificationAttributeOption
                    {
                        Name = "SpecificationAttributeOption name 1",
                        DisplayOrder = 1,
                    }
                );
            var fromDb = SaveAndLoadEntity(specificationAttribute);
            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("Name 1");

            fromDb.SpecificationAttributeOptions.ShouldNotBeNull();
            (fromDb.SpecificationAttributeOptions.Count == 1).ShouldBeTrue();
            fromDb.SpecificationAttributeOptions.First().Name.ShouldEqual("SpecificationAttributeOption name 1");
        }
Exemplo n.º 6
0
 public static SpecificationAttribute ToEntity(this SpecificationAttributeModel model, SpecificationAttribute destination)
 {
     return Mapper.Map(model, destination);
 }
        protected virtual void InstallSpecificationAttributes()
        {
            var sa1 = new SpecificationAttribute
            {
                Id = 1,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "Screensize",
                DisplayOrder = 1,
            };
            sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {

                Id = 1,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "13.0''",
                DisplayOrder = 2,
                SpecificationAttributeId = 1,
            });
            sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 2,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "13.3''",
                DisplayOrder = 3,
                SpecificationAttributeId = 1,
            });
            sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 3,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "14.0''",
                DisplayOrder = 4,
                SpecificationAttributeId = 1,
            });
            sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 4,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "15.0''",
                DisplayOrder = 4,
                SpecificationAttributeId = 1,
            });
            sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 5,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "15.6''",
                DisplayOrder = 5,
                SpecificationAttributeId = 1,
            });
            var sa2 = new SpecificationAttribute
            {
                Id = 2,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "CPU Type",
                DisplayOrder = 2,
            };
            sa2.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 1,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "Intel Core i5",
                DisplayOrder = 1,
                SpecificationAttributeId = 2,
            });
            sa2.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 2,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "Intel Core i7",
                DisplayOrder = 2,
                SpecificationAttributeId = 2,
            });
            var sa3 = new SpecificationAttribute
            {
                Id = 3,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "Memory",
                DisplayOrder = 3,
            };
            sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 1,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "4 GB",
                DisplayOrder = 1,
                SpecificationAttributeId = 3,
            });
            sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 2,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "8 GB",
                DisplayOrder = 2,
                SpecificationAttributeId = 3,
            });
            sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 3,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "16 GB",
                DisplayOrder = 3,
                SpecificationAttributeId = 3,
            });
            var sa4 = new SpecificationAttribute
            {
                Id = 4,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "Hardrive",
                DisplayOrder = 5,
            };
            sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 1,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "128 GB",
                DisplayOrder = 7,
                SpecificationAttributeId = 4,
            });
            sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 2,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "500 GB",
                DisplayOrder = 4,
                SpecificationAttributeId = 4,
            });
            sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
            {
                Id = 3,
                _id = ObjectId.GenerateNewId().ToString(),
                Name = "1 TB",
                DisplayOrder = 3,
                SpecificationAttributeId = 4,
            });
            var specificationAttributes = new List<SpecificationAttribute>
                                {
                                    sa1,
                                    sa2,
                                    sa3,
                                    sa4
                                };
            _specificationAttributeRepository.Insert(specificationAttributes);
        }
 protected virtual void InstallSpecificationAttributes()
 {
     var sa1 = new SpecificationAttribute
     {
         Name = "Screensize",
         DisplayOrder = 1,
     };
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "10.0''",
         DisplayOrder = 3,
     });
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "14.1''",
         DisplayOrder = 4,
     });
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "15.4''",
         DisplayOrder = 5,
     });
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "16.0''",
         DisplayOrder = 6,
     });
     var sa2 = new SpecificationAttribute
     {
         Name = "CPU Type",
         DisplayOrder = 2,
     };
     sa2.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "AMD",
         DisplayOrder = 1,
     });
     sa2.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "Intel",
         DisplayOrder = 2,
     });
     var sa3 = new SpecificationAttribute
     {
         Name = "Memory",
         DisplayOrder = 3,
     };
     sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "1 GB",
         DisplayOrder = 1,
     });
     sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "3 GB",
         DisplayOrder = 2,
     });
     var sa4 = new SpecificationAttribute
     {
         Name = "Hardrive",
         DisplayOrder = 5,
     };
     sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "320 GB",
         DisplayOrder = 7,
     });
     sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "250 GB",
         DisplayOrder = 4,
     });
     sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption()
     {
         Name = "160 GB",
         DisplayOrder = 3,
     });
     var specificationAttributes = new List<SpecificationAttribute>
                         {
                             sa1,
                             sa2,
                             sa3,
                             sa4
                         };
     specificationAttributes.ForEach(sa => _specificationAttributeRepository.Insert(sa));
 }
Exemplo n.º 9
0
        private void ResolveProductSpecificationAttributes(ProductResolveInput input, Product product)
        {
            IPagedList<SpecificationAttribute> existingAttributes = _attributeService.GetSpecificationAttributes();
            IList<ProductSpecificationAttribute> existingProductSpecificationAttributes =
                _attributeService.GetProductSpecificationAttributesByProductId(product.Id);
            foreach (SpecificationAttributeInput attr in input.ProductInputRow.ProductSpecificationAttributeInput)
            {
                SpecificationAttribute spesAttr = existingAttributes.FirstOrDefault(x => x.Name == attr.Name);
                SpecificationAttributeOption spesAttrOption;
                if (spesAttr != null)
                {
                    //check options
                    spesAttrOption = spesAttr.SpecificationAttributeOptions.FirstOrDefault(x => x.Name == attr.Value);
                    if (spesAttrOption == null)
                    {
                        spesAttrOption = new SpecificationAttributeOption
                        {
                            Name = attr.Value,
                            DisplayOrder = 1,
                            SpecificationAttribute = spesAttr,
                            SpecificationAttributeId = spesAttr.Id
                        };
                        _attributeService.InsertSpecificationAttributeOption(spesAttrOption);
                    }
                }
                else
                {
                    spesAttr = new SpecificationAttribute
                    {
                        Name = attr.Name,
                        DisplayOrder = 1
                    };
                    _attributeService.InsertSpecificationAttribute(spesAttr);

                    spesAttrOption = new SpecificationAttributeOption
                    {
                        Name = attr.Value,
                        DisplayOrder = 1,
                        SpecificationAttribute = spesAttr,
                        SpecificationAttributeId = spesAttr.Id
                    };
                    _attributeService.InsertSpecificationAttributeOption(spesAttrOption);
                }

                if (
                    existingProductSpecificationAttributes.FirstOrDefault(
                        x => x.SpecificationAttributeOptionId == spesAttrOption.Id) == null)
                {
                    _attributeService.InsertProductSpecificationAttribute(new ProductSpecificationAttribute
                    {
                        AllowFiltering = attr.IncludeInFilter.InvariantEquals("yes"),
                        ShowOnProductPage = attr.ShowOnProductPage.InvariantEquals("yes"),
                        DisplayOrder = 1,
                        Product = product,
                        ProductId = product.Id,
                        SpecificationAttributeOption = spesAttrOption,
                        SpecificationAttributeOptionId = spesAttrOption.Id
                    });
                }
            }
        }
Exemplo n.º 10
0
 protected virtual void InstallSpecificationAttributes()
 {
     var sa1 = new SpecificationAttribute
     {
         Name = "Screensize",
         DisplayOrder = 1,
     };
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "13.0''",
         DisplayOrder = 2,
     });
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "13.3''",
         DisplayOrder = 3,
     });
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "14.0''",
         DisplayOrder = 4,
     });
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "15.0''",
         DisplayOrder = 4,
     });
     sa1.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "15.6''",
         DisplayOrder = 5,
     });
     var sa2 = new SpecificationAttribute
     {
         Name = "CPU Type",
         DisplayOrder = 2,
     };
     sa2.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "Intel Core i5",
         DisplayOrder = 1,
     });
     sa2.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "Intel Core i7",
         DisplayOrder = 2,
     });
     var sa3 = new SpecificationAttribute
     {
         Name = "Memory",
         DisplayOrder = 3,
     };
     sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "4 GB",
         DisplayOrder = 1,
     });
     sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "8 GB",
         DisplayOrder = 2,
     });
     sa3.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "16 GB",
         DisplayOrder = 3,
     });
     var sa4 = new SpecificationAttribute
     {
         Name = "Hardrive",
         DisplayOrder = 5,
     };
     sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "128 GB",
         DisplayOrder = 7,
     });
     sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "500 GB",
         DisplayOrder = 4,
     });
     sa4.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "1 TB",
         DisplayOrder = 3,
     });
     var sa5 = new SpecificationAttribute
     {
         Name = "Color",
         DisplayOrder = 1,
     };
     sa5.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "Grey",
         DisplayOrder = 2,
         ColorSquaresRgb = "#8a97a8"
     });
     sa5.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "Red",
         DisplayOrder = 3,
         ColorSquaresRgb = "#8a374a"
     });
     sa5.SpecificationAttributeOptions.Add(new SpecificationAttributeOption
     {
         Name = "Blue",
         DisplayOrder = 4,
         ColorSquaresRgb = "#47476f"
     });
     var specificationAttributes = new List<SpecificationAttribute>
                         {
                             sa1,
                             sa2,
                             sa3,
                             sa4,
                             sa5
                         };
     _specificationAttributeRepository.Insert(specificationAttributes);
 }
 protected virtual List<LocalizedProperty> UpdateAttributeLocales(SpecificationAttribute specificationAttribute, SpecificationAttributeModel model)
 {
     List<LocalizedProperty> localized = new List<LocalizedProperty>();
     foreach (var local in model.Locales)
     {
         if (!(String.IsNullOrEmpty(local.Name)))
             localized.Add(new LocalizedProperty()
             {
                 LanguageId = local.LanguageId,
                 LocaleKey = "Name",
                 LocaleValue = local.Name,
                 _id = ObjectId.GenerateNewId().ToString(),
                 Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
             });
     }
     return localized;
 }
        /// <summary>
        /// Deletes a specification attribute
        /// </summary>
        /// <param name="specificationAttribute">The specification attribute</param>
        public virtual void DeleteSpecificationAttribute(SpecificationAttribute specificationAttribute)
        {
            if (specificationAttribute == null)
                throw new ArgumentNullException("specificationAttribute");


            var builder = Builders<Product>.Update;
            var updatefilter = builder.PullFilter(x => x.ProductSpecificationAttributes, y => y.SpecificationAttributeId == specificationAttribute.Id);
            var result = _productRepository.Collection.UpdateManyAsync(new BsonDocument(), updatefilter).Result;

            _specificationAttributeRepository.Delete(specificationAttribute);

            _cacheManager.RemoveByPattern(PRODUCTSPECIFICATIONATTRIBUTE_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityDeleted(specificationAttribute);
        }