Auto set update date on save of Custom Part

Topics: Customizing Orchard
Jul 31, 2013 at 5:00 PM
I need to set a property every time (UpdateDate) on a custom part but am not having any luck.

I have tried in the Driver in the Editor post (both before and after the updater.TryUpdateModel call.

I have tried in the Handler by setting in OnUpdating and OnUpdated.

How do I hook into the pipeline?

Jul 31, 2013 at 7:02 PM
Edited Jul 31, 2013 at 7:03 PM
Doing it in the Editor post method is the way to go. Without seeing exactly what you tried, it's hard to say why that failed. The handler should work too.
Jul 31, 2013 at 7:50 PM
I must have been having other issues (specifically a not null datetime field throwing errors on insert), this did work:
protected override DriverResult Editor(StorePart part, IUpdateModel updater, dynamic shapeHelper)
            if (updater.TryUpdateModel(part, Prefix, null, null))
                part.UpdateDate = DateTime.Now;

            return Editor(part, shapeHelper);
Thank you.