public bool Evaluate(IRuleExecutionContext context) { var contact = RuleExecutionContextExtensions.Fact <Contact>(context); XConnectClient client = XConnectClientReference.GetClient(); Contact existingContact = client.Get <Contact>(contact, new ContactExpandOptions(CvPersonFacet.DefaultFacetKey)); CvPersonFacet personFacet = existingContact.GetFacet <CvPersonFacet>(CvPersonFacet.DefaultFacetKey); Log.Information("AgeMatches personFacet is null == " + (personFacet == null).ToString()); if (personFacet == null || personFacet.Age == 0) { return(false); } Log.Information("AgeMatches personFacet.Age == " + personFacet.Age); bool result = NumericOperationTypeExtensions.Evaluate(this.Comparison, personFacet.Age, this.Age); Log.Information("AgeMatches result == " + result.ToString()); return(result); }
public bool Evaluate(IRuleExecutionContext context) { var contact = RuleExecutionContextExtensions.Fact <Contact>(context, null); int airQuality = _airService.GetAirQualityForContact(contact); if (Comparison == NumericOperationType.IsNotEqualTo) { return(airQuality != AirQuality); } return(NumericOperationTypeExtensions.Evaluate(Comparison, airQuality, AirQuality)); }