Beispiel #1
0
        public async Task <IActionResult> LinkAttributeValuesToProducts(ManageAttributesViewModel model)
        {
            ICollection <ProductAttributeValue> pavs = new List <ProductAttributeValue>();

            foreach (var attrValId in model.IdsOfSelectedAttributeValues)
            {
                foreach (var productId in model.IdsOfSelectedProducts)
                {
                    ProductAttributeValue pav = new ProductAttributeValue()
                    {
                        AttributeValueId = attrValId,
                        ProductId        = productId
                    };
                    pavs.Add(pav);
                }
            }

            await _attributeService.AddProductAttributeValueRange(pavs);

            return(RedirectToAction("Index"));
        }