Cancelled appointment change still saves

4 posts, 0 answers
  1. Brandon
    Brandon avatar
    15 posts
    Member since:
    Nov 2009

    Posted 28 Jul 2015 Link to this post

    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?

  2. Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 30 Jul 2015 Link to this post

    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
  3. DevCraft banner
  4. Brandon
    Brandon avatar
    15 posts
    Member since:
    Nov 2009

    Posted 30 Jul 2015 in reply to Nasko Link to this post

    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);
            }
        }
    }

     

     

  5. Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 03 Aug 2015 Link to this post

    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
Back to Top