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

Forums / Developing with Sitefinity / Saving Event Changes

Saving Event Changes

6 posts, 0 answered
  1. Tech
    Tech avatar
    26 posts
    Registered:
    13 Sep 2010
    13 Jan 2011
    Link to this post
    Greetings,

    I'm trying to save changes to an IEvent object (such as the start/end dates for the event, and the Status of the content) using the Telerik.Events.EventsManager.SaveContent() method, however it requires a IContent object, not an IEvent object.  I tried casting the IEvent as an IContent, but it can't make the cast, and there doesn't seem to be another way to save changes to those fields of the IEvent object.  Can anyone help me out?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Jan 2011
    Link to this post
    Hi Phillip,

    The IEvent has a property ContentItem that you can use. You can directly work with ContentManager class if necessary.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Tech
    Tech avatar
    26 posts
    Registered:
    13 Sep 2010
    13 Jan 2011
    Link to this post
    Thanks! I was under the impression from the documentation that the ContentItem object was just the base content information for the Event, not including the start/end time and other IEvent specific properties.  When I save changes to the ContentItem, it will save those as well?

    Thanks!
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Jan 2011
    Link to this post
    Hello Phillip,

    Using EventsManager you create IContent item. Since the Events module is based on the Generic Content module, a large number of methods used for manipulating Events are performed by ContentManager (initialized with a proper Events provider). Every event is actually an object of IContent type. So, in order to allow access to content manipulation methods , EventsManager exposes the public property Content of type ContentManager. This allows developers to use common methods for retrieving, creating, updating and deleting content as well as comments, categories and tags.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Tech
    Tech avatar
    26 posts
    Registered:
    13 Sep 2010
    13 Jan 2011
    Link to this post
    Understood, but I think I'm still somewhat confused.  Take the following code:

    Telerik.Events.IEvent ev = (Telerik.Events.IEvent)Application["ev"];
    ev.Start = DateTime.Parse(textbox_start.Text);
    ev.End = DateTime.Parse(textbox_end.Text);
     
    switch (radio_status.Text)
    {
        case "Draft":
            ev.ContentItem.Status = ContentStatus.Draft;
            break;
        case "Published":
            ev.ContentItem.Status = ContentStatus.Published;
            break;
        case "Archived":
            ev.ContentItem.Status = ContentStatus.Archived;
            break;
    }
     
    Telerik.Events.EventsManager mgr = new Telerik.Events.EventsManager("Events");
    mgr.SaveContent(ev.ContentItem);

    Now, if I try to use the EventsManager.SaveContent() method on the ContentItem within the IEvent object, I get a message that the ContentItem belongs to a different provider (which makes sense). However, if I just try to do:

    mgr.SaveContent((IContent)ev);

    I can't cast that IEvent object as a IContact object, .Net throws an error.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Jan 2011
    Link to this post
    Hello Phillip,

    This might help.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
6 posts, 0 answered