public CheckLimitationsResult CheckLimitations(Discount discount, CartModel cart)
        {
            var limitations = _session.QueryOver<DiscountLimitation>()
                .Where(limitation => limitation.Discount.Id == discount.Id)
                .Cacheable()
                .List();

            var results = new CheckLimitationsResult[limitations.Count];
            for (var i = 0; i < limitations.Count; i++)
            {
                var limitation = limitations[i];
                var fullName = limitation.GetType().FullName;
                if (LimitationCheckerTypes.ContainsKey(fullName))
                {
                    var checker = _kernel.Get(LimitationCheckerTypes[fullName]) as DiscountLimitationChecker;
                    if (checker != null)
                    {
                        results[i] = checker.CheckLimitations(limitation, cart);
                        continue;
                    }
                }
                results[i] = CheckLimitationsResult.CurrentlyInvalid("Limitation cannot be checked");
            }
            return CheckLimitationsResult.Combine(results);
        }
 public static CheckLimitationsResult Successful(IEnumerable<CartItem> applicableItems, params string[] messages)
 {
     var checkLimitationsResult = new CheckLimitationsResult
     {
         Status = CheckLimitationsResultStatus.Success,
         Messages = messages
     };
     if (applicableItems != null)
         checkLimitationsResult.CartItems.AddRange(applicableItems);
     return checkLimitationsResult;
 }
Beispiel #3
0
        public static CheckLimitationsResult Successful(IEnumerable <CartItem> applicableItems, params string[] messages)
        {
            var checkLimitationsResult = new CheckLimitationsResult
            {
                Status   = CheckLimitationsResultStatus.Success,
                Messages = messages
            };

            if (applicableItems != null)
            {
                checkLimitationsResult.CartItems.AddRange(applicableItems);
            }
            return(checkLimitationsResult);
        }
Beispiel #4
0
 public DiscountInfo(Discount discount, CheckLimitationsResult checkLimitationsResult)
 {
     _discount = discount;
     _checkLimitationsResult = checkLimitationsResult;
 }
 public abstract DiscountApplicationInfo Apply(DiscountApplication application, CartModel cart, CheckLimitationsResult checkLimitationsResult);
Beispiel #6
0
 public DiscountInfo(Discount discount, CheckLimitationsResult checkLimitationsResult)
 {
     _discount = discount;
     _checkLimitationsResult = checkLimitationsResult;
 }