public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement) { Dictionary <string, object> changes = new Dictionary <string, object>(); Device refInCache = null; if (Id != Guid.Empty) { refInCache = CacheHelper.GetDeviceFromCache(memoryCache, Id); if (refInCache != null) { if (Name != null && !Name.Equals(refInCache.Name)) { changes.Add("Name", Name); refInCache.Name = Name; } if (HardwareId != null && !HardwareId.Equals(refInCache.HardwareId)) { changes.Add("HardwareId", HardwareId); refInCache.HardwareId = HardwareId; } if (SpaceId != null && !SpaceId.Equals(refInCache.SpaceId)) { changes.Add("SpaceId", SpaceId); refInCache.SpaceId = SpaceId; } if (Type != null && !Type.Equals(refInCache.Type)) { changes.Add("Type", Type); refInCache.Type = Type; } if (SubType != null && !SubType.Equals(refInCache.SubType)) { changes.Add("SubType", SubType); refInCache.SubType = SubType; } } else { refInCache = this; if (Name != null) { changes.Add("Name", Name); } if (HardwareId != null) { changes.Add("HardwareId", HardwareId); } if (SpaceId != null) { changes.Add("SpaceId", SpaceId); } if (Type != null) { changes.Add("Type", Type); } if (SubType != null) { changes.Add("SubType", SubType); } } } updatedElement = refInCache; return(changes); }
public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement) { Dictionary <string, object> changes = new Dictionary <string, object>(); Sensor refInCache = null; if (Id != Guid.Empty) { refInCache = CacheHelper.GetSensorFromCache(memoryCache, Id); if (refInCache != null) { if (!DeviceId.Equals(refInCache.DeviceId)) { changes.Add("DeviceId", DeviceId); refInCache.DeviceId = DeviceId; } if (HardwareId != null && !HardwareId.Equals(refInCache.HardwareId)) { changes.Add("HardwareId", HardwareId); refInCache.HardwareId = HardwareId; } if (SpaceId != null && !SpaceId.Equals(refInCache.SpaceId)) { changes.Add("SpaceId", SpaceId); refInCache.SpaceId = SpaceId; } if (!PollRate.Equals(refInCache.PollRate)) { changes.Add("PollRate", PollRate); refInCache.PollRate = PollRate; } if (PortType != null && !PortType.Equals(refInCache.PortType)) { changes.Add("PortType", PortType); refInCache.PortType = PortType; } if (DataType != null && !DataType.Equals(refInCache.DataType)) { changes.Add("DataType", DataType); refInCache.DataType = DataType; } if (DataUnitType != null && !DataUnitType.Equals(refInCache.DataUnitType)) { changes.Add("DataUnitType", DataUnitType); refInCache.DataUnitType = DataUnitType; } if (DataSubtype != null && !DataSubtype.Equals(refInCache.DataSubtype)) { changes.Add("DataSubtype", DataSubtype); refInCache.DataSubtype = DataSubtype; } } else { refInCache = this; if (DeviceId != null) { changes.Add("DeviceId", DeviceId); } if (HardwareId != null) { changes.Add("HardwareId", HardwareId); } if (SpaceId != null) { changes.Add("SpaceId", SpaceId); } if (PollRate != 0) { changes.Add("PollRate", PollRate); } if (PortType != null) { changes.Add("PortType", PortType); } if (DataType != null) { changes.Add("DataType", DataType); } if (DataUnitType != null) { changes.Add("DataUnitType", DataUnitType); } if (DataSubtype != null) { changes.Add("DataSubTypeId", DataSubTypeId); } } } updatedElement = refInCache; return(changes); }