Esempio n. 1
0
        public void SaveInfo(int pvId)
        {
            ProductVariant productVariant = ProductManager.GetProductVariantById(pvId);

            if (productVariant != null)
            {
                List <int> selectedDiscountIds = this.DiscountMappingControl.SelectedDiscountIds;
                var        existingDiscounts   = DiscountManager.GetDiscountsByProductVariantId(productVariant.ProductVariantId);

                var allDiscounts = DiscountManager.GetAllDiscounts(DiscountTypeEnum.AssignedToSKUs);
                foreach (Discount discount in allDiscounts)
                {
                    if (selectedDiscountIds.Contains(discount.DiscountId))
                    {
                        if (existingDiscounts.Find(d => d.DiscountId == discount.DiscountId) == null)
                        {
                            DiscountManager.AddDiscountToProductVariant(productVariant.ProductVariantId, discount.DiscountId);
                        }
                    }
                    else
                    {
                        if (existingDiscounts.Find(d => d.DiscountId == discount.DiscountId) != null)
                        {
                            DiscountManager.RemoveDiscountFromProductVariant(productVariant.ProductVariantId, discount.DiscountId);
                        }
                    }
                }
            }
        }
        public void SaveInfo()
        {
            ProductVariant productVariant = ProductManager.GetProductVariantByID(ProductVariantID);

            if (productVariant != null)
            {
                foreach (Discount discount in DiscountManager.GetDiscountsByProductVariantID(productVariant.ProductVariantID))
                {
                    DiscountManager.RemoveDiscountFromProductVariant(productVariant.ProductVariantID, discount.DiscountID);
                }
                foreach (int discountID in DiscountMappingControl.SelectedDiscountIDs)
                {
                    DiscountManager.AddDiscountToProductVariant(productVariant.ProductVariantID, discountID);
                }
            }
        }