Пример #1
0
        public static JObject UpdateThing(long referenceId, JObject updates)
        {
            Thing thing;

            if (!XmlSaveLoad.Referencables.TryGetValue(referenceId, out thing))
            {
                return(null);
            }

            try
            {
                JsonTranslator.UpdateObjectFromJson(updates, thing);
            }
            catch (JsonTranslationException e)
            {
                throw new BadRequestException(e.Message);
            }
            return(JsonTranslator.ObjectToJson(thing));
        }
Пример #2
0
        public static JObject UpdateDevice(long referenceId, JObject updates)
        {
            var device = Device.AllDevices.Find(x => x.ReferenceId == referenceId);

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

            try
            {
                JsonTranslator.UpdateObjectFromJson(updates, device);
            }
            catch (JsonTranslationException e)
            {
                throw new BadRequestException(e.Message);
            }
            return(JsonTranslator.ObjectToJson(device));
        }