Replies: 2 comments
-
In most of my UIs, for example, I call it a lot as the page/form loads so I can disable or change which controls are rendered so the user has an obvious signal that the property can't be changed (by them). What you are describing, I think, is the need for a custom authorization rule that takes into account the other property values. That's exactly the purpose behind custom authorization rules. Using that technique you shouldn't have to do any special code at all, because the behaviors should work as expected. In short, overriding |
Beta Was this translation helpful? Give feedback.
-
This is 1.5 years after the original post, but I recently had to deal with a similar situation. I was working on an OData API that uses editable business objects in the data modification methods (i.e. Post, Put, and Patch). I got tired of repeatedly writing checks that the value changed, so we added the following method to our custom BusinessBase subclass:
This simplified our Dto -> BusinessBase mapping code to this style: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have some logic around whether or not a property is editable in the CanWriteProperty method override. This is based on other readonly properties on my object. The problem I having is that the CanWriteProperty method is being fired when I attempt to set the property to same value, from an API method. Within my Edit method, I take a model from the caller, I get the Customer object from the datastore, and then I set each editable property from the model that's passed in. So, in my case the value of this property hasn't changed, but the CanWriteProperty is still firing off the Csla.Security.SecurityException.
While I can add in a check in the property to see if the value is different from the current value of my property, it just seems like a bug that the CanWriteProperty doesn't take into account whether or not the property value has changed.
Not sure if that makes sense, but wanted to see if this is a bug in the framework?
Beta Was this translation helpful? Give feedback.
All reactions