public void UpdateOptionLocales(SpecificationAttributeOption specificationAttributeOption, SpecificationAttributeOptionModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEntityService.SaveLocalizedValue(specificationAttributeOption,
                                                        x => x.Name,
                                                        localized.Name,
                                                        localized.LanguageId);
     }
 }
        public void Can_save_and_load_specificationAttributeOption()
        {
            var specificationAttributeOption = new SpecificationAttributeOption
            {
                Name = "SpecificationAttributeOption name 1",
                DisplayOrder = 1,
                SpecificationAttribute = new SpecificationAttribute
                {
                    Name = "SpecificationAttribute name 1",
                    DisplayOrder = 2,
                }
            };

            var fromDb = SaveAndLoadEntity(specificationAttributeOption);
            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("SpecificationAttributeOption name 1");
            fromDb.DisplayOrder.ShouldEqual(1);

            fromDb.SpecificationAttribute.ShouldNotBeNull();
            fromDb.SpecificationAttribute.Name.ShouldEqual("SpecificationAttribute name 1");
        }
示例#3
0
 public static SpecificationAttributeOption ToEntity(this SpecificationAttributeOptionModel model, SpecificationAttributeOption destination)
 {
     return Mapper.Map(model, destination);
 }
        /// <summary>
        /// Updates the specification attribute
        /// </summary>
        /// <param name="specificationAttributeOption">The specification attribute option</param>
        public virtual void UpdateSpecificationAttributeOption(SpecificationAttributeOption specificationAttributeOption)
        {
            if (specificationAttributeOption == null)
                throw new ArgumentNullException("specificationAttributeOption");

            _specificationAttributeOptionRepository.Update(specificationAttributeOption);

            _cacheManager.RemoveByPattern(PRODUCTSPECIFICATIONATTRIBUTE_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityUpdated(specificationAttributeOption);
        }
示例#5
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
                    });
                }
            }
        }
 protected virtual List<LocalizedProperty> UpdateOptionLocales(SpecificationAttributeOption specificationAttributeOption, SpecificationAttributeOptionModel 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;
 }
        protected virtual SpecificationAttributeOption GetSpecOptionByName(int specAttribute, string name)
        {
            var specOption = new SpecificationAttributeOption();

            var options = _specificationAttributeService.GetSpecificationAttributeOptionsBySpecificationAttribute(specAttribute);
            if (options.Count == 0)
                return specOption;

            foreach (SpecificationAttributeOption so in options)
            {
                if (so.Name == name)
                    return so; ;
            }

            return specOption;

        }