Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
hi,
I have an applicationeventhandler that listens for the publish of content if it's of type Product it needs to do some extra stuff.
However whenever I try TryToConvert<> it fails to convert even though i can see it's of type Product. Think I'm missing something?
Code is here:
public class ProductPublishHook : ApplicationEventHandler { protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { core.ContentService.Published += ContentServicePublished; } private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args) { foreach (IContent node in args.PublishedEntities) { if (node.ContentType.Alias == "product") { Attempt<Product> productAttempt = node.TryConvertTo<Product>(); // more login here } } } }
TryConvertTo says it's unable to cast. Product only implments IPublishedContent. daaaaa
anyone got an idea?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
ApplicationEventHandler - publish content event - convert IContent to model builder
hi,
I have an applicationeventhandler that listens for the publish of content if it's of type Product it needs to do some extra stuff.
However whenever I try TryToConvert<> it fails to convert even though i can see it's of type Product. Think I'm missing something?
Code is here:
TryConvertTo says it's unable to cast. Product only implments IPublishedContent. daaaaa
anyone got an idea?
is working on a reply...