Get parent node name into IApplicationEventHandler
Hi guys,
I built a class that inherit from IApplicationEventHandler to intercept the media Item save.
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
/* La chiamata si verifica dopo il salvataggio. */
MediaService.Saved += MediaServiceSaved;
}
void MediaServiceSaved(IMediaService sender, SaveEventArgs<IMedia> e)
{
..........
foreach (IMedia mediaItem in e.SavedEntities)
{
int parentId = mediaItem.ParentId;
string path = mediaItem.Path;
Node parentNode = new Node(parentId);
......
}
Now I need to take the parentNode.Name but parentNode is always null.
My question is: How can I get the parentNode usgin parentId, I need to take the folder name where I'm uploading the image.
Get parent node name into IApplicationEventHandler
Hi guys, I built a class that inherit from IApplicationEventHandler to intercept the media Item save.
Now I need to take the parentNode.Name but parentNode is always null. My question is: How can I get the parentNode usgin parentId, I need to take the folder name where I'm uploading the image.
Thanks in advance. Dante.
Hi Dante,
you are in the Media section. So the parent node is also an media item.
Take the MediaService to get the parent node
Stefan
Hi Stefan, thank you very much for your support.
Regards. Dante
is working on a reply...