Sometimes these changes I make seem so obvious that I pause to wonder what other factors I'm not considering.
The Save method overrides in the PT business objects do some checking for the user's authorization to perform the save operation, and then call the base.Save method if they all pass.
I made the CanAddObject, CanDeleteObject, and CanEditObject methods abstract in my CustomBusinessBase : BusinessBase class and then moved all that authorization checking in there as well.
But that makes me wonder why Rocky didn't do that in BusinessBase in the first place.
Thoughts?
Well, didn't take me long to get that answer. Those methods are static (shared) to enable some use in the UI, and you can't have abstract (or virtual for that matter) static methods unfortunately.
Yeah, it seems like a severe limitation that I would expect is solvable by the compiler team. But then, I'm just talking out my posterior orifice when it comes to that :D
Since this is generated/snippet code anyway I'm not going to worry about it.
If I find myself frequently needing to have instance versions of these authorization checks anyway then I'll revisit this.
My plan would be to have abstract instance methods CanEditThisObject, CanDeleteThisObject, etc. in the CustomBusinessBase class. The default implementation in the business object would be to just return the corresponding static/shared call. The CusomtBusinessBase Save override in CustomBusinessBase could then use the instance version and do that authorization checking as I originally planned.
Copyright (c) Marimer LLC