public override bool Validate(RuleClause ruleClause, object argument)
        {
            CustomerOrder customerOrder = argument as CustomerOrder;

            if (customerOrder == null)
            {
                throw new ArgumentException("argument must be of type CustomerOrder");
            }
            bool yes = ruleClause.CriteriaValue.EqualsIgnoreCase("Yes");

            if (yes)
            {
                foreach (OrderLine ol in customerOrder.OrderLines)
                {
                    if (ol.Product.IsSubscription)
                    {
                        var containsIsSubscriptionOpted = ol.CustomProperties.Where(x => x.Name.EqualsIgnoreCase("isSubscriptionOpted")).Count();
                        if (containsIsSubscriptionOpted > 0)
                        {
                            var IsSubscriptionOpted = ol.CustomProperties.Where(x => x.Name.EqualsIgnoreCase("isSubscriptionOpted")).FirstOrDefault();
                            if (IsSubscriptionOpted.Value.EqualsIgnoreCase("true"))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
        public override bool Validate(RuleClause ruleClause, object argument)
        {
            CustomerOrder customerOrder = argument as CustomerOrder;

            if (customerOrder == null)
            {
                throw new ArgumentException("argument must be of type CustomerOrder");
            }
            bool yes = ruleClause.CriteriaValue.EqualsIgnoreCase("Yes");

            if (yes)
            {
                return(true);
            }

            return(false);
        }
        public override bool Validate(RuleClause ruleClause, object argument)
        {
            CustomerOrder customerOrder = argument as CustomerOrder;

            if (customerOrder == null)
            {
                throw new ArgumentException("argument must be of type CustomerOrder");
            }
            Guid categoryId  = this.TryParseGuid("SimpleValue", ruleClause.SimpleValue);
            bool isBasePrice = ruleClause.CriteriaValue.EqualsIgnoreCase("BasePrice");

            var is_PromotionBasePrice = customerOrder.OrderLines.Where <OrderLine>((Func <OrderLine, bool>)(o =>
            {
                ICollection <Category> categories = o.Product.Categories;
                int count = 0;
                foreach (Category category in categories)
                {
                    if (categoryId == category.Id)
                    {
                        count++;
                    }
                }
                if (count == 0)
                {
                    return(false);
                }
                if (o.Product.IsQuoteRequired)
                {
                    return(ruleClause.RuleManager.Name != "Promotion");
                }
                return(true);
            })).Where(o => o.UnitNetPrice == o.UnitListPrice);

            if (is_PromotionBasePrice.Count() > 0 && isBasePrice)
            {
                return(true);
            }
            return(false);
        }
        public override bool Validate(RuleClause ruleClause, object argument)
        {
            if (!(argument is CustomerOrder))
            {
                throw new ArgumentException("argument must be of type CustomerOrder");
            }
            int num = ((CustomerOrder)argument).OrderLines.Sum(o =>
            {
                if (!OrderLineUtilities.GetIsActive(o))
                {
                    return(0);
                }
                //if (o.Product.IsQuoteRequired)
                //    return ruleClause.RuleManager.Name != "Promotion";
                return((int)o.QtyOrdered);
            });
            string comparisonOperator1 = ruleClause.ComparisonOperator;
            RuleClauseComparisonOperator comparisonOperator2 = RuleClauseComparisonOperator.Range;
            string str1 = comparisonOperator2.ToString();

            if (comparisonOperator1 == str1)
            {
                int result1;
                if (!int.TryParse(ruleClause.ValueMinimum, NumberStyles.Any, CultureInfo.InvariantCulture, out result1))
                {
                    throw new ArgumentException("ValueMinimum must be integer, it was " + ruleClause.ValueMinimum);
                }
                int result2;
                if (!int.TryParse(ruleClause.ValueMaximum, NumberStyles.Any, CultureInfo.InvariantCulture, out result2))
                {
                    throw new ArgumentException("ValueMaximum must be integer, it was " + ruleClause.ValueMaximum);
                }
                if (result1 <= num)
                {
                    return(num <= result2);
                }
                return(false);
            }
            int result;

            if (!int.TryParse(ruleClause.SimpleValue, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
            {
                throw new ArgumentException("SimpleValue must be integer, it was " + ruleClause.SimpleValue);
            }
            string comparisonOperator3 = ruleClause.ComparisonOperator;

            comparisonOperator2 = RuleClauseComparisonOperator.Equals;
            string str2 = comparisonOperator2.ToString();

            if (comparisonOperator3 == str2)
            {
                return(result == num);
            }
            string comparisonOperator4 = ruleClause.ComparisonOperator;

            comparisonOperator2 = RuleClauseComparisonOperator.NotEquals;
            string str3 = comparisonOperator2.ToString();

            if (comparisonOperator4 == str3)
            {
                return(result != num);
            }
            string comparisonOperator5 = ruleClause.ComparisonOperator;

            comparisonOperator2 = RuleClauseComparisonOperator.GreaterThan;
            string str4 = comparisonOperator2.ToString();

            if (comparisonOperator5 == str4)
            {
                return(result < num);
            }
            string comparisonOperator6 = ruleClause.ComparisonOperator;

            comparisonOperator2 = RuleClauseComparisonOperator.GreaterThanOrEqual;
            string str5 = comparisonOperator2.ToString();

            if (comparisonOperator6 == str5)
            {
                return(result <= num);
            }
            string comparisonOperator7 = ruleClause.ComparisonOperator;

            comparisonOperator2 = RuleClauseComparisonOperator.LessThan;
            string str6 = comparisonOperator2.ToString();

            if (comparisonOperator7 == str6)
            {
                return(result > num);
            }
            string comparisonOperator8 = ruleClause.ComparisonOperator;

            comparisonOperator2 = RuleClauseComparisonOperator.LessThanOrEqual;
            string str7 = comparisonOperator2.ToString();

            if (comparisonOperator8 == str7)
            {
                return(result >= num);
            }
            throw new ArgumentException("ComparisonOperator is not valid, it was " + ruleClause.ComparisonOperator);
        }