Added example with AndAlso and OrElse (#12)

pull/14/head
Abbas Cyclewala 2020-04-23 09:30:44 +05:30 committed by GitHub
parent 63087f4f2a
commit af53705ab5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 6 deletions

View File

@ -2,13 +2,13 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<StartupObject>DemoApp.NestedInputDemo</StartupObject> <StartupObject>DemoApp.Program</StartupObject>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RulesEngine" Version="1.0.1" /> <ProjectReference Include="../../src/RulesEngine/RulesEngine/RulesEngine.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -35,12 +35,57 @@
"Expression": "input1.loyalityFactor > 3 AND input1.totalPurchasesToDate >= 50000 AND input1.totalPurchasesToDate <= 100000 AND input2.totalOrders > 5 AND input3.noOfVisitsPerMonth > 15" "Expression": "input1.loyalityFactor > 3 AND input1.totalPurchasesToDate >= 50000 AND input1.totalPurchasesToDate <= 100000 AND input2.totalOrders > 5 AND input3.noOfVisitsPerMonth > 15"
}, },
{ {
"RuleName": "GiveDiscount35", "RuleName": "GiveDiscount30NestedOrExample",
"SuccessEvent": "30",
"ErrorMessage": "One or more adjust rules failed.",
"ErrorType": "Error",
"Operator": "OrElse",
"Rules":[
{
"RuleName": "IsLoyalAndHasGoodSpend",
"ErrorMessage": "One or more adjust rules failed.",
"ErrorType": "Error",
"RuleExpressionType": "LambdaExpression",
"Expression": "input1.loyalityFactor > 3 AND input1.totalPurchasesToDate >= 50000 AND input1.totalPurchasesToDate <= 100000"
},
{
"RuleName": "OrHasHighNumberOfTotalOrders",
"ErrorMessage": "One or more adjust rules failed.",
"ErrorType": "Error",
"RuleExpressionType": "LambdaExpression",
"Expression": "input2.totalOrders > 15"
}
]
},
{
"RuleName": "GiveDiscount35NestedAndExample",
"SuccessEvent": "35", "SuccessEvent": "35",
"ErrorMessage": "One or more adjust rules failed.", "ErrorMessage": "One or more adjust rules failed.",
"ErrorType": "Error", "ErrorType": "Error",
"RuleExpressionType": "LambdaExpression", "Operator": "AndAlso",
"Expression": "input1.loyalityFactor > 3 AND input1.totalPurchasesToDate >= 100000 AND input2.totalOrders > 15 AND input3.noOfVisitsPerMonth > 25" "Rules": [
{
"RuleName": "IsLoyal",
"ErrorMessage": "One or more adjust rules failed.",
"ErrorType": "Error",
"RuleExpressionType": "LambdaExpression",
"Expression": "input1.loyalityFactor > 3"
},
{
"RuleName": "AndHasTotalPurchased100000",
"ErrorMessage": "One or more adjust rules failed.",
"ErrorType": "Error",
"RuleExpressionType": "LambdaExpression",
"Expression": "input1.totalPurchasesToDate >= 100000"
},
{
"RuleName": "AndOtherConditions",
"ErrorMessage": "One or more adjust rules failed.",
"ErrorType": "Error",
"RuleExpressionType": "LambdaExpression",
"Expression": "input2.totalOrders > 15 AND input3.noOfVisitsPerMonth > 25"
}
]
} }
] ]
} }

5
global.json Normal file
View File

@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.1.101"
}
}