Quantcast
Channel: CSLA .NET
Viewing all articles
Browse latest Browse all 764

Combination of Business Rule and Valdation Rule

$
0
0

I develop a WinForm application with CSLA 4.3.13 and I have the following case:

I have a class with three properties:

CurrentValue

MaxValue

Result

The validation rule is CurrentValue<MaxValue

The business rule is that changing the value of the Result property changes the value of the MaxValue property.

I wrote the following rules to implement this scenario:

BusinessRules.AddRule(new Rules.MaxValueGetFromResult(MaxValueProperty, ResultProperty) { Priority = -1 });  //Business Rule

BusinessRules.AddRule(new Rules.LessThanProperty(CurrentValueProperty, MaxValueProperty) ); //Validation Rule

My problem is that when the user changes the Result property the validation rule is executed before the business rule and for that reason it uses the old value of MaxValue property and not the one that is set after the execution of the business rule.
Thanks

Viewing all articles
Browse latest Browse all 764

Trending Articles