You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the database does not apply changes made to a Scheduler event, you need to delete the database so that the changes will be applied the next time you run the project.
609
+
:::
610
+
611
+
### Updating API Controller
612
+
613
+
Lastly, we need to modify our PUT/POST/DELETE actions in order to handle [special rules of recurring events](guides/recurring-events.md#editingdeleting-a-certain-occurrence-in-the-series).
614
+
615
+
First, let's take a look at the POST action. We need to process a special case for recurring events: deletion of a specific occurrence of the recurring series requires creating a new database record and the client will call the insert action for it:
616
+
617
+
618
+
~~~js title="Controllers/SchedulerController.cs"
619
+
// POST: api/scheduler/5
620
+
[HttpPost]
621
+
public IHttpActionResult CreateSchedulerEvent(WebAPIEvent webAPIEvent)
622
+
{
623
+
var newSchedulerEvent = (SchedulerEvent)webAPIEvent;
624
+
var action = "inserted";
625
+
if (webAPIEvent.deleted == true) /*!*/
626
+
{
627
+
// delete a single occurrence from a recurring series
628
+
action = "deleted"; /*!*/
629
+
}
630
+
db.SchedulerEvents.Add(newSchedulerEvent);
631
+
db.SaveChanges();
632
+
633
+
return Ok(new
634
+
{
635
+
tid = newSchedulerEvent.Id,
636
+
action
637
+
});
638
+
}
639
+
~~~
640
+
641
+
In the PUT action we need to make sure to update all properties of the model. Additionally, we need to handle a different special case there: when a recurring series is modified, we need to delete all modified occurrences of that series:
642
+
643
+
644
+
~~~js title="Controllers/SchedulerController.cs"
645
+
// PUT: api/scheduler/5
646
+
[HttpPut]
647
+
public IHttpActionResult EditSchedulerEvent(int id, WebAPIEvent webAPIEvent)
648
+
{
649
+
var updatedSchedulerEvent = (SchedulerEvent)webAPIEvent;
The approach below applies to events stored in the legacy pre-7.1 format (`event_pid`, `rec_type`, `event_length`). Use it only if you still maintain data that uses those fields; new projects should use the rrule-based engine described above. See the [migration guide](migration.md#new-engine-for-recurring-events) and the [legacy recurring events guide](guides/recurring-events-legacy.md) for context.
730
+
:::
731
+
732
+
To stay on the legacy engine, enable the `recurring_legacy` plugin instead of `recurring`:
733
+
734
+
~~~js
735
+
scheduler.plugins({
736
+
recurring_legacy: true
737
+
});
738
+
~~~
739
+
740
+
#### Updating the Models
741
+
742
+
The legacy engine stores recurrence info in three columns - `event_pid`, `rec_type`, `event_length`:
Lastly, we need to modify our PUT/POST/DELETE actions in order to handle [special rules of recurring events](guides/recurring-events.md#editingdeleting-a-certain-occurrence-in-the-series).
824
+
The legacy POST/PUT/DELETE actions follow the same idea but key off `rec_type` and `event_pid`. Firstly, the `POST` action - a deleted occurrence of a recurring series is created as a new record with `rec_type == "none"`:
609
825
610
-
First, let's take a look at the POST action. We need to process a special case for recurring events: deletion of a specific occurrence of the recurring series
611
-
requires creating a new database record and the client will call the insert action for it:
612
826
613
827
~~~js title="Controllers/SchedulerController.cs"
614
828
// POST: api/scheduler/5
@@ -634,8 +848,7 @@ public IHttpActionResult CreateSchedulerEvent(WebAPIEvent webAPIEvent)
634
848
}
635
849
~~~
636
850
637
-
In the PUT action we need to make sure to update all properties of the model. Additionally, we need to handle a different special case there: when a recurring series
638
-
is modified, we need to delete all modified occurrences of that series:
851
+
In the PUT action we need to make sure to update all properties of the model. When a recurring series is modified, all modified occurrences of that series have to be deleted:
639
852
640
853
641
854
~~~js title="Controllers/SchedulerController.cs"
@@ -667,10 +880,9 @@ public IHttpActionResult EditSchedulerEvent(int id, WebAPIEvent webAPIEvent)
667
880
}
668
881
~~~
669
882
670
-
And finally, the DELETE action. Here we have to check two special cases:
883
+
And finally, the DELETE action. Two special cases:
671
884
672
-
- if the event you are going to delete has a non-empty event_pid, it means a user deletes a modified instance of the recurring series. Instead of deleting such a record from the database, you need to give it rec_type='none',
673
-
in order for scheduler to skip this occurrence.
885
+
- if the event you are going to delete has a non-empty event_pid, it means a user deletes a modified instance of the recurring series. Instead of deleting such a record from the database, you need to give it rec_type='none', in order for scheduler to skip this occurrence.
674
886
- if a user deletes a whole recurring series, you also need to delete all the modified instances of that series.
0 commit comments