예제 #1
0
        public void SaveInfo(int catId)
        {
            Category category = CategoryManager.GetCategoryById(catId);

            if (category != null)
            {
                List <int> selectedDiscountIds = this.DiscountMappingControl.SelectedDiscountIds;
                var        existingDiscounts   = DiscountManager.GetDiscountsByCategoryId(category.CategoryId);

                var allDiscounts = DiscountManager.GetAllDiscounts(DiscountTypeEnum.AssignedToCategories);
                foreach (Discount discount in allDiscounts)
                {
                    if (selectedDiscountIds.Contains(discount.DiscountId))
                    {
                        if (existingDiscounts.Find(d => d.DiscountId == discount.DiscountId) == null)
                        {
                            DiscountManager.AddDiscountToCategory(category.CategoryId, discount.DiscountId);
                        }
                    }
                    else
                    {
                        if (existingDiscounts.Find(d => d.DiscountId == discount.DiscountId) != null)
                        {
                            DiscountManager.RemoveDiscountFromCategory(category.CategoryId, discount.DiscountId);
                        }
                    }
                }
            }
        }
예제 #2
0
        public void SaveInfo()
        {
            Category category = CategoryManager.GetCategoryByID(this.CategoryID);

            if (category != null)
            {
                foreach (Discount discount in DiscountManager.GetDiscountsByCategoryID(category.CategoryID))
                {
                    DiscountManager.RemoveDiscountFromCategory(category.CategoryID, discount.DiscountID);
                }
                foreach (int discountID in DiscountMappingControl.SelectedDiscountIDs)
                {
                    DiscountManager.AddDiscountToCategory(category.CategoryID, discountID);
                }
            }
        }