Exemplo n.º 1
0
        public IList <OrderProduct> GetProducts(DiscountParameter parameter)
        {
            if (string.IsNullOrEmpty(FilterExpression))
            {
                FilterExpression = "p => true";
            }
            var query = parameter.ProductList.AsQueryable();

            return(query.Where(FilterExpression).ToList());
        }
Exemplo n.º 2
0
        public bool Validate(DiscountParameter parameter, CoreContext context)
        {
            var plist = GetProducts(parameter);

            switch (Property)
            {
            case "TotalFee":
            {
                var expressionInput                    = (decimal)plist.Sum(p => p.Counter * p.SalePrice);
                ParameterExpression paramExp           = Expression.Parameter(typeof(decimal));
                ConstantExpression  constantExpression = Expression.Constant(Convert.ToDecimal(Value));
                return(OnValidate <decimal>(paramExp, constantExpression, expressionInput));
            }

            case "TotalCount":
            {
                decimal             expressionInput    = plist.Sum(p => p.Counter);
                ParameterExpression paramExp           = Expression.Parameter(typeof(decimal));
                ConstantExpression  constantExpression = Expression.Constant(Convert.ToDecimal(Value));
                return(OnValidate <decimal>(paramExp, constantExpression, expressionInput));
            }
            }
            return(false);
        }
Exemplo n.º 3
0
 public bool Validate(DiscountParameter parameter, CoreContext context)
 {
     return(ConditionValidator.Validate(parameter, context));
 }
Exemplo n.º 4
0
        public IList <OrderProduct> GetProducts(DiscountParameter parameter)
        {
            ProductValidator productValidator = ConditionValidator as ProductValidator;

            return(productValidator.GetProducts(parameter));
        }