private void ApplyCriteria(CouponApplicabilityCriterionContext context) { if (context.IsApplicable) { var result = CookieValueForm.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; } }
public void Describe(DescribeCouponApplicabilityContext describe) { var isAvailableForConfiguration = IsAvailableForConfiguration(); var isAvailableForProcessing = IsAvailableForProcessing(); describe .For("Request", T("Http Request"), T("Http Request")) .Element("Test request cookies", T("Test request cookies"), T("Test request cookies"), (ctx) => ApplyCriteria(ctx), (ctx) => ApplyCriteria(ctx), (ctx) => CookieValueForm.DisplayFilter(ctx.State, T), isAvailableForConfiguration, isAvailableForProcessing, CookieValueForm.FormName); }