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));
        }
        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));
        }