コード例 #1
0
        private void FixupTimeEntries(TimeEntry previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.CreditNote.Contains(this))
            {
                previousValue.CreditNote.Remove(this);
            }

            if (TimeEntries != null)
            {
                if (!TimeEntries.CreditNote.Contains(this))
                {
                    TimeEntries.CreditNote.Add(this);
                }

                TimeEntryID = TimeEntries.TimeEntryID;
            }
            else if (!skipKeys)
            {
                TimeEntryID = null;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("TimeEntries") &&
                    (ChangeTracker.OriginalValues["TimeEntries"] == TimeEntries))
                {
                    ChangeTracker.OriginalValues.Remove("TimeEntries");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("TimeEntries", previousValue);
                }
                if (TimeEntries != null && !TimeEntries.ChangeTracker.ChangeTrackingEnabled)
                {
                    TimeEntries.StartTracking();
                }
            }
        }