Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ssougnez/ca4306f7b1315615fe6fec5086e72ff2 to your computer and use it in GitHub Desktop.
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