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

Cancelled appointment change still saves

3 Answers 39 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Brandon asked on 28 Jul 2015, 01:27 PM

I am duplicating an issue with the WPF_CS database project from the sdk_master. 

When I edit an appointment and make a change and then click cancel, the appointment is still updated in the List of appointments, so when you edit it again it has the changes made previously. 

This then causes the save routine to automatically save back the changes when the save is fired (or in my case any navigation is made away from the schedule)

How can I rollback the appointment on a cancel?

3 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 30 Jul 2015, 08:54 AM
Hello Brandon,

We were able to observe the described by you behavior of RadScheduleView. What we could suggest you as one possible workaround is to create a field of type SqlAppointment inside the SqlAppointment class. As soon as you begin to edit an Appointment the BeginEdit method will be called - inside it you need to set the field with the current value of the appointment. So, when you click the Cancel button the CancelEdit method will be called and inside it you need to revert the value of the currently edited appointment to the value that was preserved inside the BeginEdit method.

We have modified the SDK example with the described above approach and you could run and evaluate it.

Please, give it a try and let us know if it worked for you.

Hopes 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
Brandon
Top achievements
Rank 1
answered on 30 Jul 2015, 04:53 PM

Thanks.  That was a start.  It worked for existing appointments, however newly added appointments that were cancelled still were in the Repository.  I've ​update the Remove section of the AppointmentCollectionChanged in the ViewModel and that seems to work properly:

Can you update the git project to assist others?

 

private void OnAppointmentsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
    //Synchronization with the DB
    if (e.Action == NotifyCollectionChangedAction.Add)
    {
        var app = e.NewItems == null ? null : e.NewItems[0] as SqlAppointment;
        if (app != null)
        {
            if (app.EntityState != EntityState.Unchanged && !app.IsFrequency)
            {
                app.ARNum = m_Filter.SelectedPatient.Trim();
                ScheduleViewRepository.Context.AddToSqlAppointments(app);
            }
        }
    }
    else if (e.Action == NotifyCollectionChangedAction.Remove)
    {
        var app = e.OldItems == null ? null : e.OldItems[0] as SqlAppointment;
        if (app != null)
        {
            if (ScheduleViewRepository.Context.SqlAppointments.Any(a => a.SqlAppointmentId == app.SqlAppointmentId))
            {
                if (app.RecurrenceRule != null)
                {
                    var tempList = app.RecurrenceRule.Exceptions.ToList();
                    foreach (SqlExceptionOccurrence item in tempList)
                        ScheduleViewRepository.Context.SqlExceptionOccurrences.DeleteObject(item);
                }
 
                var tempAppList = ScheduleViewRepository.Context.SqlAppointmentResources.Where(i => i.SqlAppointments_SqlAppointmentId == app.SqlAppointmentId).ToList();
                foreach (var item in tempAppList)
                    ScheduleViewRepository.Context.SqlAppointmentResources.DeleteObject(item);
            }
            ScheduleViewRepository.Context.SqlAppointments.DeleteObject(app);
        }
    }
}

 

 

0
Nasko
Telerik team
answered on 03 Aug 2015, 11:14 AM
Hi Brandon,

We are really glad that you were able to achieve the desired and we are really thankful for sharing with us the approach you used.

We will consider improving our SDK example with it.

If you have any additional questions or concerns regarding Telerik controls, please do not hesitate to contact us.

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
Brandon
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Brandon
Top achievements
Rank 1
Share this question
or