+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Event Calendar Documentation

Event Calendar Documentation

4 posts, 0 answered
  1. Mark
    Mark avatar
    147 posts
    Registered:
    01 Jun 2010
    22 May 2013
    Link to this post
    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? 
  2. Mark
    Mark avatar
    147 posts
    Registered:
    01 Jun 2010
    22 May 2013
    Link to this post
    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'.


  3. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    27 May 2013
    Link to this post
    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
  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    27 May 2013 in reply to Pavel Benov
    Link to this post
    Careful of the evil ".ToList();" :)
4 posts, 0 answered