Create events

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

When creating an event, you must perform the following:

  1. Create new event.

    First, you must create new event.

  2. Set the required properties.

    When creating a new event, it is recommended to set at least the following properties:

    • Title

    • Content

    • UrlName

    • City

    • Country

    • EventStart

    • EventEnd

    You can also set any other properties (e.g. PublicationDateExpirationDateDescriptionDateCreatedContactNameContactPhone,ContactEmailEmailAuthor, etc.) in this step.

  3. Save the event.

    Save all changes that you have made to the event.

  4. Publish the event.

    Finally, you publish the event using the workflow manager.

To create an event using the Native API, you must use the EventsManager class. For more information, see Creating an event using Native API.

To create an event using the Fluent API, you must use the event facade. For more information, see Creating an event using Fluent API.

The examples below show you how to create an event with predefined ID.

NOTE: In the code examples below the ID argument is assigned to the master version of the event.

Creating an event using Native API

The following code creates an event with the specified IDTitleContentStartDateEndDateCity and Country through the Native API.

First, you initialize the EventsManager. You create the event using the CreateEvent method of the EventsManager class. Note that you can create an event with either predefined or auto-generated ID depending on which overload of the method you use. The ID argument is assigned to the ID of the master version of the item. Then, you set the properties of the event. It is recommended to set at least the following properties: TitleContentUrlNameCityCountryEventStart and EventEnd. Then, you save the changes. Finally, to publish the event in live state, you call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.

Creating an event using Fluent API

The following code creates an event with the specified IDTitleContentStartDateEndDateCity and Country through the Fluent API.

First, you initialize the singular facade of the event by calling App.WorkWith().Event(). You create the event using the CreateNew method of the facade. The ID argument is assigned to the master version of the item. Then, you set the properties of the event by calling the Domethod of the facade. It is recommended to set at least the following properties: TitleContentUrlNameCityCountryEventStart andEventEnd. Then, you save the changes. Finally, to publish the event in live state, you call the MessageWorkflow method of theWorkflowManager class and pass the required parameters.

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?

Next article

Query events