Event Calendar Documentation

Posted by Community Admin on 04-Aug-2018 14:00

Event Calendar Documentation

All Replies

Posted by Community Admin on 22-May-2013 00:00

Sitefinity team -- the new event calendar is fantastic, fast and flexible...thank you!

I need to programatically create new event calendars, and then add events to them. I checked the documentation and didn't see anything on it yet. Can you please post some quick samples on working with them? 

Posted by Community Admin on 22-May-2013 00:00

I've been trying to find what I need through Just Decompile and it looks like I need to set the parent of event event as a calendar. I had previously assigned a custom field "BusinessCategory" to handle filtering. I'm trying to loop through all of my events and add it to a corresponding calendar but sitefinity is running into a manager issue.

EventsManager manager = EventsManager.GetManager();
 
IEnumerable<Event> events = App.WorkWith().Events().Where(ev => ev.Status == ContentLifecycleStatus.Master).Get().ToList();
IList<Event> filteredEvents = new List<Event>();
IEnumerable<Event> matchingEvents = events.Where(ev => ev.GetSafeCustomField<string>("BusinessCategory") != String.Empty).ToList();
             
foreach (Event thisEvent in matchingEvents)
    switch (thisEvent.GetSafeCustomField<string>("BusinessCategory"))
    
        case "1":
            //Business Planning
            thisEvent.Parent = manager.GetCalendars().Where(c => c.Title == "Business Planning").FirstOrDefault();
            manager.SaveChanges();
            break;
        case "2":
            //Funding/Accounting
            thisEvent.Parent = manager.GetCalendars().Where(c => c.Title == "Funding/Accounting").FirstOrDefault();
            manager.SaveChanges();
            break;
        default:
            break;
    

When it hits the GetCalendars() portion for a switch case it is showing: Object references between two different object scopes are not allowed. The object 'Telerik.Sitefinity.Events.Model.Calendar' is already managed by 'ObjectScopeImpl 0x24 OpenAccessRuntime.EnlistableObjectScope' and was tried to be managed again by 'ObjectScopeImpl 0x23 OpenAccessRuntime.EnlistableObjectScope'.


Posted by Community Admin on 27-May-2013 00:00

Hello Mark,

Try getting the events list at the beginning with the Native API like so:

var events = manager.GetEvents().Where(ev => ev.Status == ContentLifecycleStatus.Master).ToList();

I hope this helps.

Regards,
Pavel Benov
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 27-May-2013 00:00

Careful of the evil ".ToList();" :)

This thread is closed