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

Delete Occurrence / Recurrence Exceptions in code?

3 Answers 160 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 27 Nov 2012, 04:07 AM
Hi All,

Can someone tell me what is the correct way to handle deletes programmatically for occurrences and recurrence exceptions?

Deleting a simple, non-recurring booking with a call to RadScheduleView.Remove(apptA) causes the RadScheduleView.AppointmentDeleted event to fire.. From this event, we can remove apptA from our data store--finalising the "delete" operation. The same path is taken when deleting a recurring series. Removing the series "Master" from the RadScheduleView and then the data store removes all occurrences.

But what about deleting only one occurrence out of several or deleting an exception to the recurrence rule? This does not cause AppointmentDeleted to fire, so how do we finalise the "delete" operation? What happens behind the scenese? What entities are affected?

Also, according to this page, "you can delete an appointment using the code. Just Call Remove() method of the RadScheduleView control. It returns whether or not the appointment or the occurrence can be removed." Why might an appointment NOT be removable? Also note that we are managing our AppointmentSource, loading and unloading appointments as users move forward and back in time. We are not able to use the CollectionChanged handler of this collection to watch for deletions or additions.

Thanks for your help--
Scott


3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 29 Nov 2012, 01:38 PM
Hi Scott,

When an occurrence of a recurrent appointment is deleted, AppointmentEditing and AppointmentEdited events of the ScheduleView are fired. In AppointmentEditing event handler the second argument which is of type AppointmentEditingEventArgs has IsDeleted property - it is true when the occurrence is deleted, false when the occurrence is edited. More information about RadScheduleView events can be found here.

As to the second question - the method returns false in cases when the parameter is not of type IAppointment or Occurrence, also when you try to delete an appointment which is at the same time in edit mode.

Hope this helps. If you have any additional issues/questions, please let us know.

Kind regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Simon
Top achievements
Rank 1
answered on 03 Dec 2012, 03:58 AM
Hi Yana,

Thanks--It is becoming clearer now. One more question: when deleting a recurrence exception (Occurrence.State = RecurrenceState.Exception), what code should I add to "persist" the deletion in our dataset?

I see that I can use ScheduleViewAppointmentEditing event handler to identify the deletion by testing for 
((appointmentEditingEventArgs.Occurrence.State == RecurrenceState.Exception) && appointmentEditingEventArgs.IsDeleted)

Then what? Should I remove the appointEditingEventArgs.Occurrence from the appointmentEditingEventArgs.Appointment.RecurrenceRule.Exceptions collection? Or should I somehow use appointmentEditingEventArgs.Appointment.RecurrenceRule.RemoveException() method?

If I do nothing, the recurrence exception appears again as soon as I reload my Appointment data from the database.

Cheers,
Scott
0
Yana
Telerik team
answered on 05 Dec 2012, 01:44 PM
Hello Scott,

I am not sure how your database is designed.  If you're following our example ( check the database diagram here), you will have SqlExceptionOccurrences table where all the exception dates from the RecurrenceRule are saved and SqlExceptionAppointments table where the properties for the exceptions are preserved.  These tables should be updated when deleting/editing occurrences.

Hope this helps.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ScheduleView
Asked by
Simon
Top achievements
Rank 1
Answers by
Yana
Telerik team
Simon
Top achievements
Rank 1
Share this question
or