Delete events

Sitefinity CMS allows you to delete events through the Events API.

When deleting an event, you must perform the following:

  1. Get the event.
    First, you must get the master version of the event corresponding to the specified ID.
    For more information, see For developers: Query events and For developers: Find events.
  2. Delete the event.
    After you get the master version of the event, you delete it.
  3. Save the changes.

To delete an event you can use the Native API or the Fluent API.

NOTE: The code examples below work with the ID of the master version of the event. Deleting the master version also deletes the other versions of the item. For more information about deleting items using the ID of the live version, see For developers: Delete content.

Delete an event by its ID

The following examples delete an event by the ID of its master version:

Native API

First, you initialize the EventsManager. Then, you get the master version of the event using GetEvents and filtering based on the Id property. To delete the event, you call the DeleteEvent method passing the master version as argument. Finally, you save the changes.

Fluent API

First, you initialize the plural facade of the event using App.WorkWith().Events(). Then, you filter based on the Id property to assure that the event exists. To get the master version of the event, you use the singular facade of the event.

NOTE: If there is no event with the specified IdEvent(masterEventId) throws an exception of type ItemNotFoundException.

To delete the event, you use the Delete method of the facade. Finally, you save the changes.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?