using System; using System.Collections.Generic; using System.Text.RegularExpressions; using Telerik.Sitefinity.Events.Model; using Telerik.Sitefinity.Workflow; namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Events { public partial class EventsSnippets { public static void CreateEventFluentAPI(Guid eventId, string title, string content, DateTime startDate, DateTime endDate, string city, string country) { // Create the event App.WorkWith().Event().CreateNew(eventId) .Do(e => { // Set the event properties e.Title = title; e.Content = content; e.UrlName = Regex.Replace(title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); e.City = city; e.Country = country; e.EventStart = startDate; e.EventEnd = endDate; e.PublicationDate = DateTime.Today; }) .Publish() .SaveChanges(); } } }