Example #1
0
        public void ApplyRewards(IEnumerable <PromotionReward> rewards)
        {
            var productRewards = rewards.Where(r => r.RewardType == PromotionRewardType.CatalogItemAmountReward && r.ProductId == Id);

            if (productRewards == null)
            {
                return;
            }

            Discounts.Clear();

            foreach (var reward in productRewards)
            {
                var discount = reward.ToDiscountModel(Price.SalePrice.Amount, Price.Currency);

                if (reward.IsValid)
                {
                    Discounts.Add(discount);
                }
            }

            Price.ActiveDiscount = Discounts.FirstOrDefault();
        }