Hi Dojo,
I am trying to move reservation to new time slot, however I keep getting "ExecutionTime must be before the end of the ReservationInstance" exception.
I'm doing the following:
- Get reservation to move
- Remove all events
- Set new time range for the reservation
- Add events with new time stamps
- Update reservation
Job object that is passed as argument to these methods comes from the same flow, just two different outcomes, so there is no difference between those. In CreateReservation method everything works fine, but on the UpdateReservation method I get the aforementioned exception. The method ReservationInstance.AddEvent checks if executionTime(first parameter) is > then ReservationInstance.End, which would mean that executionTime == ReservationInstance.End should be valid, as it is in the CreateReservation.
Any idea what might be causing this and how can I fix it?
Thanks,
Cheers
Hi Edib,
When you do NewTimeRange you need to add those the objects to a new list and then use that one, as currently that is not doing anything.
Thanks Jorge, manged to get it working. Here is the updated code:
Not really related with the question, but consider not doing all ForEach, but just one, and also pass all updated reservations at once to method AddOrUpdateReservationInstances to improve the performance.
Hi Jorge,
So technically, I’m not actually supposed to update current reservation. I will delete existing one and create a new one in it’s place? I thought ri = ri.NewTimeRange would achieve that since I’m replacing original instances with updated ones and since NewTimeRange only does shallow copy I figured that would work.