SaveAsync behavior #3283
Unanswered
CROprogrammer
asked this question in
Questions
Replies: 1 comment 3 replies
-
Have you looked at overriding SaveAsync in the business class? You should be able to do something like this pseudocode: protected override SaveAsync()
{
if (this.IsNew)
{
await BusinessRules.CheckRulesAsync();
}
return await base.SaveAsync();
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've created my business object in which I have implemented [Create] and [Insert] methods, and I'm using Blazor for UI. I didn't want that business rules are checked on creation of business object because then I get validation messages even though inputs have not been touched. Then I tried to remove BusinessRules.CheckRules() from Create method to not get those messages but then I'm able to save empty object in database because my business rules are not checked when I click save button that calls ViewModel.SaveAsync() method. Why is that. How can I accomplish that business rules are checked after I click save button and that empty object is not going to be saved but business rules are going to be checked beforehand.
I've tried to put BusinessRules.CheckRules() in the body of Insert method but then it works just the first time I try to save my object (it checks the business rules and I get validation messages) but then after when I insert valid data in my form and click save nothing happens (SaveAsync does not even call Insert method again).
TLDR: How can I accomplish that SaveAsync method in Blazor checks business rules before calling Insert method in BusinessBase object
Im using CSLA 5.5.3
Beta Was this translation helpful? Give feedback.
All reactions