This is a migrated thread and some comments may be shown as answers.

How to retrieve the recurrence pattern of an appointment

3 Answers 102 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Divya
Top achievements
Rank 1
Divya asked on 06 Mar 2020, 12:59 PM

Hi,

I need to retrieve the recurrence pattern and set it to our custom object. I tried various methods. In all these cases, I am not able to retrieve DaysOfWeekMask which holds values like "Sunday" or "Monday|Tuesday|Wednesday" and cast it to our custom object DaysOfWeek which is also an enum.

1st Method

a) RecurrenceDays days = new RecurrenceDays();
days = days.AddDay(CurrentCreatedAppointment.RecurrenceRule.Pattern.DaysOfWeekMask);
var s = days.GetDaysOfWeek().Select(x => (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), x.ToString())).AsEnumerable();
viewModel.BackupArchiveSettings.ByDay = new ObservableCollection<DaysOfWeek>( s);
var k = s.GetEnumerator();

var k1 = k.Current;

 

2nd Method

 RecurrenceDays days = new RecurrenceDays();
days = days.AddDay(CurrentCreatedAppointment.RecurrenceRule.Pattern.DaysOfWeekMask);
var s = days.GetDaysOfWeek().Select(x => (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), x.ToString())).AsEnumerable();

newcol = new ObservableCollection<DaysOfWeek>();
foreach (var item in s.ToList())
{
 viewModel.BackupArchiveSettings.ByDay.Add(item);
}

 

Please help

 

Thanks,

Divya

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 11 Mar 2020, 10:16 AM

Hello Divya,

To get the recurrence pattern of an appointment, you can use its RecurrenceRule and the Pattern property, as you are already doing.

var pattern = CurrentCreatedAppointment.RecurrenceRule.Pattern;

Note that the Appointment elements doesn't have a recurrence rule set by default, so in the situations where the property is not set explicitly its value will be null. A similar statement applies for the DaysOfWeekMask property - if not defined explicitly, its value is None.

Can you tell me what exactly doesn't work on your side? And also when your code is executed? It would be useful, if you could isolate the issue in a runnable project and send it over.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Divya
Top achievements
Rank 1
answered on 01 Apr 2020, 11:19 AM

Sorry for delayed reply. And thank you for your response

I was able to achieve the same by these steps

                   var days = CurrentCreatedAppointment.RecurrenceRule.Pattern.DaysOfWeekMask.GetDaysOfWeek();                    
                    foreach (var day in days)
                    {
                        viewModel.BackupSettings.ByDay.Add((DaysOfWeek)((int)day));
                    }

Thanks

0
Martin Ivanov
Telerik team
answered on 01 Apr 2020, 02:38 PM

Hi Divya,

It is good to hear that you managed to resolve this.

Regards,
Martin Ivanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Divya
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Divya
Top achievements
Rank 1
Share this question
or