Appointment class - Calculate when is the next appointment

7 posts, 1 answers
  1. Dean
    Dean avatar
    6 posts
    Member since:
    Jan 2012

    Posted 30 Dec 2015 Link to this post

    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 ?
  2. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 31 Dec 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dean
    Dean avatar
    6 posts
    Member since:
    Jan 2012

    Posted 31 Dec 2015 Link to this post

    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

  5. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 04 Jan Link to this post

    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
  6. Dean
    Dean avatar
    6 posts
    Member since:
    Jan 2012

    Posted 06 Jan Link to this post

    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

  7. Dean
    Dean avatar
    6 posts
    Member since:
    Jan 2012

    Posted 06 Jan in reply to Dean Link to this post

    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

  8. Answer
    Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 11 Jan Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready