Ejemplo n.º 1
0
        private void ApplyCriteria(CouponApplicabilityCriterionContext context)
        {
            if (context.IsApplicable)
            {
                var result = HeaderValueForm.GetFilterPredicate(context.State)(_httpContextAccessor.Current().Request);

                if (!result)
                {
                    context.ApplicabilityContext.Message =
                        T("Coupon code {0} is not valid", context.CouponRecord.Code);
                }
                context.IsApplicable = result;
                context.ApplicabilityContext.IsApplicable = result;
            }
        }
Ejemplo n.º 2
0
        public void Describe(DescribeCouponApplicabilityContext describe)
        {
            var isAvailableForConfiguration = IsAvailableForConfiguration();
            var isAvailableForProcessing    = IsAvailableForProcessing();

            describe
            .For("Request", T("Http Request"), T("Http Request"))
            .Element("Test request header",
                     T("Test request header"),
                     T("Test request header"),
                     (ctx) => ApplyCriteria(ctx),
                     (ctx) => ApplyCriteria(ctx),
                     (ctx) => HeaderValueForm.DisplayFilter(ctx.State, T),
                     isAvailableForConfiguration, isAvailableForProcessing,
                     HeaderValueForm.FormName);
        }