private void FixupPromotion(Promotion previousValue) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.PromotionVehicles.Contains(this)) { previousValue.PromotionVehicles.Remove(this); } if (Promotion != null) { if (!Promotion.PromotionVehicles.Contains(this)) { Promotion.PromotionVehicles.Add(this); } PromotionId = Promotion.Id; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("Promotion") && (ChangeTracker.OriginalValues["Promotion"] == Promotion)) { ChangeTracker.OriginalValues.Remove("Promotion"); } else { ChangeTracker.RecordOriginalValue("Promotion", previousValue); } if (Promotion != null && !Promotion.ChangeTracker.ChangeTrackingEnabled) { Promotion.StartTracking(); } } }
public bool Equals(Promotion other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; if (other.Id == 0 && Id == 0) return false; else return other.Id == Id; }