I need to intercept the Save method, do some validations, alter some properties and then let it go again normally.
How can I do this?
Thanks! Alex
I would recommend adding the following partial methods to be fired before their actual action:
OnSave(CancelEventArgs e);
OnAdd(CancelEventArgs e);
OnUpdate(CancelEventArgs e);
OnDelete(CancelEventArgs e);
This isn't an event but I would use CancelEventArgs anyway, it's friendly, people know it and know how to use it and with it the actual action can be canceled from the partial methods.
These two should be added too to the list of the existing ones that fire after their actual action:
OnAdded();
OnUpdated();
I don't like that OnAdded() name but if Add was adopted instead of Insert then we must stick with it.
And that's it... With these partials I think we cover all the befores and afters of the actual data persistence methods giving us a greater flexibility to do whatever we want we our data.
I can implement this but I'm always afraid of touching the tt files because future updates will wipe off all my custom changes! :)
Thanks! Alex