Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class DocumentEventHandlerRegistration : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Saving += ContentService_Saving;
ContentService.Saved += ContentService_Saved;
ContentService.Publishing += ContentService_Publishing;
}
private void ContentService_Saved(IContentService sender, SaveEventArgs<IContent> e)
{
if ((e.SavedEntities.FirstOrDefault().ContentType.Alias == "documentTypeA" || e.SavedEntities.FirstOrDefault().ContentType.Alias == "documentTypeB") && e.SavedEntities.FirstOrDefault().ContentType.Alias != "documentTypeC")
{
// Do stuff
}
}
private void ContentService_Publishing(IPublishingStrategy sender, PublishEventArgs<IContent> e)
{
if ((e.PublishedEntities.FirstOrDefault().ContentType.Alias == "documentTypeA" || e.PublishedEntities.FirstOrDefault().ContentType.Alias == "documentTypeB") && e.PublishedEntities.FirstOrDefault().ContentType.Alias != "documentTypeC")
{
// Do stuff
}
}
private void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e)
{
if ((e.SavedEntities.FirstOrDefault().ContentType.Alias == "documentTypeA" || e.SavedEntities.FirstOrDefault().ContentType.Alias == "documentTypeB") && e.SavedEntities.FirstOrDefault().ContentType.Alias != "documentTypeC")
{
// Do stuff
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.