public bool Evaluate(IRuleExecutionContext context)
        {
            //Get configuration
            string  specificCategory     = Ny_SpecificCategory.Yield(context);
            decimal specificValue        = Ny_SpecificValue.Yield(context);
            bool    includeSubCategories = Ny_IncludeSubCategories.Yield(context);

            if (string.IsNullOrEmpty(specificCategory) || specificValue == 0 || Ny_Compares == null)
            {
                return(false);
            }

            //Get Data
            var commerceContext = context.Fact <CommerceContext>();
            List <CartLineComponent> categoryLines = AsyncHelper.RunSync(() =>
                                                                         categoryOrderLinesResolver.Resolve(commerceContext, specificCategory, includeSubCategories));

            if (categoryLines == null)
            {
                return(false);
            }

            //Validate data against configuration
            decimal productAmount = categoryLines.Sum(x => x.Quantity);

            return(Ny_Compares.Evaluate(productAmount, specificValue));
        }
        public bool Evaluate(IRuleExecutionContext context)
        {
            var commerceContext = context.Fact <CommerceContext>();

            //Get configuration
            string  specificCategory     = Ny_SpecificCategory.Yield(context);
            decimal specificValue        = Ny_SpecificValue.Yield(context);
            bool    includeSubCategories = Ny_IncludeSubCategories.Yield(context);

            if (string.IsNullOrEmpty(specificCategory) || specificValue == 0 || Ny_Compares == null)
            {
                return(false);
            }

            //Get data
            IEnumerable <CartLineComponent> categoryLines =
                categoryCartLinesResolver.Resolve(commerceContext, specificCategory, includeSubCategories);

            if (categoryLines == null)
            {
                return(false);
            }

            //Validate data against configuration
            decimal categoryTotal = categoryLines.Sum(line => line.Totals.GrandTotal.Amount);

            return(Ny_Compares.Evaluate(categoryTotal, specificValue));
        }