To create an event you can use the Native API or the Fluent API.
When creating an event, you must perform the following:
Create new event.
First, you must create new event.
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. PublicationDate, ExpirationDate, Description, DateCreated, ContactName, ContactPhone,ContactEmail, EmailAuthor, etc.) in this step.
Save the event.
Save all changes that you have made to the event.
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.
The following code creates an event with the specified ID, Title, Content, StartDate, EndDate, City 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: Title, Content, UrlName, City, Country, EventStart 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.
The following code creates an event with the specified ID, Title, Content, StartDate, EndDate, City 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: Title, Content, UrlName, City, Country, EventStart 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.
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.
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.
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.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important