With some notifications like ContentMovedToRecycleBinNotification and ContentDeletedNotification the return type is IContent, not IPublishedContent like the notifications from ContentUnpublishedNotification and ContentPublishedNotification.
When extracting the values from IPublishedContent it's fairly straight forward, but when trying to do the same for IContent I often end up with paths to related documents like umb://document/b7b20e1fe0b14f79866e42dc24b9cc8f, instead of the document itself or in another example where I have a toggle/boolean, which in the IContent object simply has information about the property, but not the actual value of the property.
How do I get to my values in IContent? Or do I have to do something different to work around it and avoid IContent altogether?
or maybe try to inject the Umbraco helper and use the Enity.Id to get the IPublished content.
This one may not work for ContentDeletedNotification as the item will not exist anymore
public class Testing : INotificationHandler<ContentMovedToRecycleBinNotification>
{
private readonly UmbracoHelper _umbracoHelper;
public Testing (IHttpContextAccessor contextAccessor)
{
if (contextAccessor.HttpContext == null) throw new NullReferenceException("Can not get umbraco context");
_umbracoHelper = contextAccessor.HttpContext.RequestServices.GetRequiredService<UmbracoHelper>();
}
Notification return types and extracting values
With some notifications like
ContentMovedToRecycleBinNotification
andContentDeletedNotification
the return type isIContent
, notIPublishedContent
like the notifications fromContentUnpublishedNotification
andContentPublishedNotification
.When extracting the values from
IPublishedContent
it's fairly straight forward, but when trying to do the same forIContent
I often end up with paths to related documents likeumb://document/b7b20e1fe0b14f79866e42dc24b9cc8f
, instead of the document itself or in another example where I have a toggle/boolean, which in theIContent
object simply has information about the property, but not the actual value of the property.How do I get to my values in
IContent
? Or do I have to do something different to work around it and avoidIContent
altogether?Hi,
have you tried something like this?
or maybe try to inject the Umbraco helper and use the Enity.Id to get the IPublished content.
This one may not work for ContentDeletedNotification as the item will not exist anymore
}
is working on a reply...