Async business rule causing SaveObjectAsync to return false #3336
-
In my BusinessBase object I have added async business rule which checks that my object is unique. Because of that, I have noticed that in my MVC application first time when I add new object (in my case role) everything works fine. Then other times when I try to create/edit object, SaveObjectAsync returns false because my object is marked busy because of my business rule. Any tip how to avoid that problem so that my object is not busy when SaveObjectAsync is being called? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
There's a There is an I also seem to remember that we implemented something that you could await when |
Beta Was this translation helpful? Give feedback.
-
I ended up overriding
|
Beta Was this translation helpful? Give feedback.
What is happening here, is that the MVC data binding creates the
RoleEdit
instance and loads the properties of the object. That runs the rules as the properties are set.When I say "MVC data binding", in reality this is handled by a CSLA-specific implementation in CslaModelBinder.
Looking at the implementation, I can see where it might be wise to rework this to call
CheckRulesAsync
instead ofCheckRules
and entirely abstract the issue into the binder. This change would probably address your issue without any special code in any individual controller.My recommendation to you is to take a copy of
CslaModelBinder
, switch theCheckRules
call, and configure aspnetcore to use this binder inste…