Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jun 09, 2016 @ 11:43
    Chriztian Steinmeier
    0

    How to correctly store a CalendarEvent value?

    Hi again,

    So I need to transition from having a couple of "normal" DatePicker properties (startDate and endDate) to the full calendar property.

    I wrote a script to copy the values over (by building the JSON and saving it using ContentService), but it doesn't seem to work reliably for all dates...

    What's the "correct" way to store a CalendarEvent type property from code?

    /Chriztian

  • Ole Martin Bakke 112 posts 624 karma points
    Jun 09, 2016 @ 14:12
    Ole Martin Bakke
    0

    Hi, I think you can do this by using the CalendarEvent class in the KS.Umbraco7.Calendar.Core namespace and convert it to JSON using Newtonsoft.

    Maybe something like this:

       var data = new KS.Umbraco7.Calendar.Core.CalendarEvent();
      data.recurrence = 0;
      data.startDate = DateTime.Now;
    data.endDate = DateTime.Now.AddHours(2);
    
     var json = Newtonsoft.Json.JsonCovert.SerializeObject(data);
    

    The CalendarEvent look like this:

     public class CalendarEvent
        {
            public int recurrence { get; set; } // 1 - not recurring, 2 - repeat daily, 3 - repeat weekly, 4 - repeat monthly, 5 - repeat yearly
            public int weekInterval { get; set; } //If repeat weekly this tells you if its every week, every 2nd week, every 3rd week etc.
            public int monthYearOption { get; set; } //1  - Use startdate, 2 - Specify weekday etc. for event
            public int? monthOption { get; set; } // 1 - Evert month, 2 - Choose months
            public int interval { get; set; } //interval of weekly events
            public int weekDay { get; set; } //weekDay for specified monthly and yearly events
            public int month { get; set; } //month for specified monthly and yearly events
            public int?[] days { get; set; } //array of days 0-6 for daily events
            public int?[] months { get; set; }//array of monts 1-12 for monthly events
            public List

    Don't add any value to the content property.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Jun 09, 2016 @ 20:09
    Chriztian Steinmeier
    0

    Thanks Ole,

    I'll try that, though it's basically what I do now — I'm just not using the event. But I will try it and see if it works :-)

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft