I have a scenatio where one of my BOs (lets call it Customer) has got a number of validation rules. So when a customer is displayed on a form, the user needs to make sure everything is correct prior to saving, which is of course normal and works fine.
Now I need to provide a batch way of updating customer BOs. The user provides the customer identifier along with key/value pairs for properties who's values should be updated. What I would like to achieve is:
Is there any elegant way of achieving this by reusing my customer BO? Should I have a different BO? If so how would I achieve that?
Thanks!
Maybe I'm missing something, but presumably you explicitly are calling ValidationRules.CheckRules() only for a new object. For an existing object, the individual rules aren't called unless the property for the rule is changed.
So, I would think this would work.
1. Load customer BO using identifier. Should be valid at this point since no rules have been checked.
2. Enumerate your key/value pairs and call property setter in BO for each present value (this will fire the rules for the properties as they are changed).
3. After setting all the changed properties, object will be valid or not.
Thanks both it was my mistake I was calling ValidationRules.CheckRules() on my base class for this app and forgot in the process... Silly user error!
Copyright (c) Marimer LLC