public bool ShouldEvaluate(IRuleContext context) { bool shouldEvaluate = true; if (context is not ICurrencyContext) { context.AddMessage(new GeneralRuleMessage { Title = "The context was not of type ICurrencyContext." }); shouldEvaluate = false; } var currencyContext = context as ICurrencyContext; if (string.IsNullOrEmpty(currencyContext.CurrencyTo) || string.IsNullOrEmpty(currencyContext.CurrencyFrom)) { context.AddMessage(new GeneralRuleMessage { Title = "The Currency Rates data was not available." }); shouldEvaluate = false; } return(shouldEvaluate); }
public bool ShouldEvaluate(IRuleContext context) { bool shouldEvaluate = true; if (context is not ICurrencyContext) { context.AddMessage(new GeneralRuleMessage { Title = "The context was not of type ICurrencyContext." }); shouldEvaluate = false; } var currencyContext = context as ICurrencyContext; if (currencyContext.CurrentValue <= 0.0) { context.AddMessage(new GeneralRuleMessage { Title = "The converted currency was zero, a fee cannot be assessed." }); shouldEvaluate = false; } return(shouldEvaluate); }