Exemple #1
0
        public static IList <PromotionsData.Promotion> GetLoyaltyPromotions(int customerId, IRuleContext ruleContext)
        {
            IList <PromotionsData.Promotion> autoAssignPromotions = new List <PromotionsData.Promotion>();

            PromotionController promotionController = CreatePromotionController();

            if (!AppLogic.AppConfigExists("AspDotNetStorefront.Promotions.excludestates"))
            {
                AppLogic.AddAppConfig("AspDotNetStorefront.Promotions.excludestates", "states to be excluded from shipping promotions", String.Empty, "", true);
            }
            string excludeConfig = AppLogic.AppConfig("AspDotNetStorefront.Promotions.excludestates");

            if (excludeConfig.Length > 0)
            {
                ruleContext.ExcludeStates = excludeConfig.Split(',');
            }
            IList <PromotionsData.Promotion> loyaltyPromotions = new List <PromotionsData.Promotion>();

            foreach (PromotionsData.Promotion promotion in PromotionsData.DataContextProvider.Current.Promotions.Where(p => p.Active))
            {
                if (promotion.PromotionRules.Where(p => p.GetType() == typeof(MinimumOrderAmountPromotionRule) || p.GetType() == typeof(MinimumOrdersPromotionRule) || p.GetType() == typeof(MinimumProductAmountOrderedPromotionRule) || p.GetType() == typeof(MinimumProductsOrderedPromotionRule)).Any())
                {
                    ruleContext.PromotionId = promotion.Id;
                    if (promotionController.ValidateLoyaltyPromotion(promotion, ruleContext))
                    {
                        loyaltyPromotions.Add(promotion);
                    }
                }
            }

            return(loyaltyPromotions);
        }