Manage events occurrences
This section guides you through the common tasks when manipulating Events Occurences through the EventsManager.
-
GetEventsOccurrences(DateTime startDate, DateTime endDate) – gets the occurrences of all live events for the specified period of time.
Here's an example: ```C# using System; using System.Collections.Generic; using Telerik.Sitefinity.Modules.Events;namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Events { public partial class EventsSnippets { public static IEnumerable
GetEventsOccurrences() { var timeNow = DateTime.UtcNow; var startRange = timeNow.AddHours(-2); var manager = EventsManager.GetManager(); var occurrences = manager.GetEventsOccurrences(startRange, startRange.AddDays(20)); return occurrences; } } } You need to specify the start date and end date between which you need to get all events. -
GetEventsOccurrences(IEnumerable<Event> events, DateTime startDate, DateTime endDate) – gets the occurrences of the specified events for the specified period of time : ```C# using System; using System.Collections.Generic; using Telerik.Sitefinity.Events.Model; using Telerik.Sitefinity.Modules.Events;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Events { public partial class EventsSnippets { public static IEnumerable
GetEventsOccurrencesByEvents() { var manager = EventsManager.GetManager(); var allEvents = manager.GetEvents(); var timeNow = DateTime.UtcNow; var startRange = timeNow.AddHours(-2); var allOccurrences = manager.GetEventsOccurrences(allEvents, startRange, startRange.AddDays(10)); return allOccurrences; } } } This is another overload of the GetEventsOccurrences method in EventsManager where you can add the events, start and end time as a parameters. This method could be helpful if you want to search amongst specific collection of events.