kenticokentico-mvc

Kentico Xperience Event - how to add new event


Kentico 13 MVC Core site build

Successful installation of:

Events are being utilized in an intranet scenario. Look for best approach to allow staff add new events to calendar without being logged into Kentico CMS. (similar to event booking system in Kentico 12 CMS portal engine)

I have created a form with event fields beneath the calendar BUT unable to locate insert statement which would populate all of the following table:

FYI: First MVC Core project

Thanks-in-advance


Solution

  • Looking at the page type classes and providers included in the NuGet package, you could use the following code to insert a new page under an Event Calendar page.

            var parentPage = EventCalendarProvider.GetEventCalendars()
                .TopN(1)
                .Culture("en-GB")
                .Published()
                .LatestVersion()
                .FirstOrDefault();
    
            var newEvent = new Event
            {
                EventName = "Test Event",
                EventSummary = "Summary Text",
                EventDescription = "Test Description",
                EventLocation = "Somewhere",
                EventStart = DateTime.Now,
                EventIsAllDay = true,
    
                // ...etc for the rest of the properties coming from the Kentico Form you've created.
            };
    
            newEvent.Insert(parentPage);
    

    If you haven't already explored it, you can use BizFormItemEvents to intercept form submissions and insert a page using the above code.