internal bool EqualsActivePeriods(AlertData other) { var equals = true; if (!CheckPeriodEndChange) { if (ActivePeriods.Any(activePeriod => !other.ActivePeriods.Any(x => x.Equals(activePeriod)))) { equals = false; } } else { foreach (var activePeriod in ActivePeriods) { var otherActivePeriod = other.ActivePeriods.FirstOrDefault(x => x.ActivePeriodStart == activePeriod.ActivePeriodStart); var seconds = otherActivePeriod != null?Math.Abs((int)activePeriod.ActivePeriodEnd - (int)otherActivePeriod.ActivePeriodEnd) : 0; equals = otherActivePeriod != null && seconds <= AlertsDataSet.ActivePeriodEndChangeSeconds; if (!equals) { break; } } } return(equals); }
internal bool EqualsExceptActivePeriods(AlertData other) { var equals = Utils.AreEqual(Cause, other.Cause) && Utils.AreEqual(Effect, other.Effect) && Utils.AreEqual(HeaderText, other.HeaderText) && Utils.AreEqual(DescriptionText, other.DescriptionText) && Utils.AreEqual(Url, other.Url) && InformedEntities.Count == other.InformedEntities.Count && ActivePeriods.Count == other.ActivePeriods.Count && Closed == other.Closed; if (!equals) { return(false); } if (InformedEntities.Any(informedEntity => !other.InformedEntities.Any(x => x.Equals(informedEntity)))) { equals = false; } return(equals); }
protected bool Equals(AlertData other) { return(EqualsExceptActivePeriods(other) && EqualsActivePeriods(other)); }