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

Appointment class - Calculate when is the next appointment

6 Answers 83 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Dean
Top achievements
Rank 1
Dean asked on 30 Dec 2015, 12:57 PM
I'm using RadScheduleView in a WPF MVVM application. The AppointmentsSource property is bound to an observable collection ObservableCollection in the ViewModel. So I have all appointments in thew view model.
How can I easily calculate if there is an ongoing appointment at the current moment ? How can I calculate when is the next appointment ?

6 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 31 Dec 2015, 12:01 PM
Hello Dean,

Please, check the attached sample that demonstrates how to achieve the desired by you functionality. Basically, inside your ViewModel using LINQ queries you could easily check if there is an Appointment ongoing at the moment and get that appointment and which is the next appointment based on the current time (using DateTime.Now).

Hope this helps.

Regards,
Nasko
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Dean
Top achievements
Rank 1
answered on 31 Dec 2015, 12:33 PM

Thank you Nasko for you sample.

Actually your sample doesn't help me. 
I use RadScheduleView only to enter the appointments. After that I have an observable collection of Appointments. I need to know based on that collection if there is an ongoing appointment at the current moment without using the UI control. Bear in mind that we could have only one Appointment that repeats every workday for the next three months from 9 am to 6 pm. How you would you find out if there is an ongoing appointment at the current moment based only on the data in the ViewModel ? 

I know that you have that code internally in your control since the control provides reminders but I need that logic outside the control. 

Thanks

0
Nasko
Telerik team
answered on 04 Jan 2016, 01:18 PM
Hi Dean,

What I could suggest you is to check the following example from our online SDK Repository that demonstrates a sample solution of implementing Appointment reminders:
https://github.com/telerik/xaml-sdk/tree/master/ScheduleView/AppointmentsReminders

It demonstrates how to implement the desired by you functionality.

We hope this will help you.

Regards,
Nasko
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Dean
Top achievements
Rank 1
answered on 06 Jan 2016, 02:38 PM

Hi, Nasko, 

 I took a look at the AppointmentsReminders sample. However, it doesn't work correctly when Recurrence is set.

For example try to set recurrence that starts two days ago and repeats every day. 

That's what I need - a correct reminder when recurrence is set. 
Anyway, I'll try to implement it myself. 

 Regards

0
Dean
Top achievements
Rank 1
answered on 06 Jan 2016, 08:50 PM

It doesn't seem to be so trivial. :-)
So if you send me a code that shows all appointments for one particular day when recurrence is set, I would appreciate it. 

 Thanks

0
Accepted
Nasko
Telerik team
answered on 11 Jan 2016, 11:06 AM
Hi Dean,

Indeed when Recurrence is set inside the AppoitnmentSource only one appointment is added. In order to get all occurrences of the desired main appointment the GetOccurrences method of the AppointmentExtensions class needs to be used:
//this.Appointments[0] is the main appointment whose occurrences you want to find
var apps = AppointmentExtensions.GetOccurrences(this.Appointments[0], DateTime.Now, DateTime.Now.AddMonths(2));

You could set the desired time range and the method will return you all recurrent appointments in that time range.

Hope this helps.

Regards,
Nasko
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
ScheduleView
Asked by
Dean
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Dean
Top achievements
Rank 1
Share this question
or