Suppose I have a two objects with a [start DateTime] and an [end DateTime] If I change the [start DateTime] and/or [end DateTime] of the 1st object, I want to like to apply that change to the next object's [start DateTime] and/or [end DateTime].
What would be the best way to do this without "The dates overlapping"?
NOTE: THE NEXT OBJECT SHOULD HAVE [start DateTime] and [end DateTime] AFTER THE FIRST OBJECT'S [start DateTime] and [end DateTime].
UPDATE THE time difference between each objects start and end time shouldn't change at all.
Example : Same date for all objects in this example. Can be different. OBJECT 1 ->>> START (07:58) END (08:28) OBJECT 2 ->>> START (08:48) END (10:30)
When OBJECT 1 is changed to ->> START (07:56) END (10:46) OBJECT 2 should change ->> START (after OBJECT 1 END) END (after OBJECT 2 START)
The differnce should be similar as well. For example, we added 2 hrs and 18 minutes to OBJECT 1 END, so OBJECT 2 should ideally have times increased by 2 hrs 18 minutes. Also, we decreased the OBJECT 1 START by 2 minutes. This should ideally be reflected in OBJECT 2 times as wll.
Current logic : PSEUDO CODE What I'm currently doing is,
var OBJECT1StartDifference = OBJECT1.OriginalStart - OBJECT1.Start;
var OBJECT1EndDifference = OBJECT1.OriginalEnd - OBJECT1.End;
ForEach(nextObject in ParentObject.where(obj => obj.Order > OBJECT1.order))
{
if(OBJECT1StartDifference.HasValue)
{
nextObject.Start.Add(OBJECT1StartDifference);
}
if(OBJECT1EndDifference.HasValue)
{
nextObject.End.Add(OBJECT1EndDifference);
}
}