Exemplo n.º 1
0
        public static DevicePayload GetDevice(long referenceId)
        {
            var device = Device.AllDevices.Find(x => x.ReferenceId == referenceId);

            if (device == null)
            {
                return(null);
            }
            return(DevicePayload.FromDevice(device));
        }
Exemplo n.º 2
0
        public static IList <DevicePayload> GetDevices()
        {
            // Devices can have duplicates in this list.
            var set = new HashSet <Device>();

            foreach (var device in Device.AllDevices)
            {
                set.Add(device);
            }
            return(set.Select(x => DevicePayload.FromDevice(x)).ToList());
        }
Exemplo n.º 3
0
        public static DevicePayload UpdateDevice(long referenceId, DevicePayload updates)
        {
            var device = Device.AllDevices.Find(x => x.ReferenceId == referenceId);

            if (device == null)
            {
                return(null);
            }

            ThingsModel.WriteThingProperties(device, updates);
            return(DevicePayload.FromDevice(device));
        }