public bool IsRecordHasNewValue(ValueHistoryRecord record) { var hasNewValue = false; if (Records.Any(r => r.PropertyName == record.PropertyName)) { var lastRecord = Records.Where(r => r.PropertyName == record.PropertyName) .OrderByDescending(r => r.RecordDate) .First(); var setting = Settings.FirstOrDefault(s => s.PropertyName == record.PropertyName); if (setting.ControlActionWhetherValueIsNew != null) { hasNewValue = setting.ControlActionWhetherValueIsNew(lastRecord.Value, record.Value); } else { hasNewValue = true; } } else { hasNewValue = true; } return(hasNewValue); }
public bool HasChangedFor(ValueHistoryRecord record) { if (IsRecordHasNewValue(record)) { if (Records.Count > 0 && Records.Any(r => r.PropertyName == record.PropertyName)) { var maxRecordDate = Records.Where(r => r.PropertyName == record.PropertyName).Max(r => r.RecordDate); if (maxRecordDate >= record.RecordDate) { record.RecordDate = maxRecordDate.AddTicks(1); } } Records.Add(record); Update(); return(true); } return(false); }