protected void UpdateLocales(CategoryProductAttributeGroup productAttribute, CategoryProductAttributeGroupModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(productAttribute, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(productAttribute, x => x.Description, localized.Description, localized.LanguageId); } }
private void UpdateDb(List <ExportCategory> categoryList, List <ExportProductAttributeValueList> productAttributeValueLists, List <ExportProductAttribute> productAttributeList) { foreach (var attr in productAttributeList) { var productAttribute = new ProductAttribute() { Name = attr.Name }; _productAttributeService.InsertProductAttribute(productAttribute); _localizedEntityService.SaveLocalizedValue(productAttribute, x => x.Name, attr.Name, 1); _localizedEntityService.SaveLocalizedValue(productAttribute, x => x.Name, attr.NameRu, 2); _localizedEntityService.SaveLocalizedValue(productAttribute, x => x.Name, attr.NameDe, 3); _localizedEntityService.SaveLocalizedValue(productAttribute, x => x.Name, attr.NameEs, 4); attr.RecievedId = productAttribute.Id; } foreach (var attributeGroup in productAttributeValueLists) { var group = new CategoryProductAttributeGroup() { Name = attributeGroup.Name }; _categoryProductAttributeService.InsertCategoryProductAttributeGroup(group); _localizedEntityService.SaveLocalizedValue(group, x => x.Name, attributeGroup.Name, 1); _localizedEntityService.SaveLocalizedValue(group, x => x.Name, attributeGroup.NameRu, 2); _localizedEntityService.SaveLocalizedValue(group, x => x.Name, attributeGroup.NameDe, 3); _localizedEntityService.SaveLocalizedValue(group, x => x.Name, attributeGroup.NameEs, 4); attributeGroup.RecievedId = group.Id; var attrs = attributeGroup.List.GroupBy(x => x.AttributeTitle); foreach (var attr in attrs) { int productAttributeId = productAttributeList.Where(x => x.Name == attr.Key).First().RecievedId; var categoryProductAttribute = new CategoryProductAttribute() { AttributeControlTypeId = (int)AttributeControlType.Checkboxes, CategoryProductGroupId = group.Id, DisplayOrder = 0, IsRequired = false, ProductAttributeId = productAttributeId }; _categoryProductAttributeService.InsertCategoryProductAttribute(categoryProductAttribute); foreach (var value in attr) { var categoryProductAttributeValue = new CategoryProductAttributeValue() { DisplayOrder = 0, CategoryProductAttributeId = categoryProductAttribute.Id, Name = value.Title, IsPreSelected = false }; _categoryProductAttributeService.InsertCategoryProductAttributeValue(categoryProductAttributeValue); _localizedEntityService.SaveLocalizedValue(categoryProductAttributeValue, x => x.Name, value.Title, 1); _localizedEntityService.SaveLocalizedValue(categoryProductAttributeValue, x => x.Name, value.TitleRu, 2); _localizedEntityService.SaveLocalizedValue(categoryProductAttributeValue, x => x.Name, value.TitleDe, 3); _localizedEntityService.SaveLocalizedValue(categoryProductAttributeValue, x => x.Name, value.TitleEs, 4); } } } foreach (var category in categoryList.Where(x => x.ParentCategoryId == 0)) { InsertChildCategories(category, categoryList, productAttributeValueLists); } }
public static CategoryProductAttributeGroupModel ToModel(this CategoryProductAttributeGroup entity) { return(Mapper.Map <CategoryProductAttributeGroup, CategoryProductAttributeGroupModel>(entity)); }
public static CategoryProductAttributeGroup ToEntity(this CategoryProductAttributeGroupModel model, CategoryProductAttributeGroup destination) { return(Mapper.Map(model, destination)); }