Пример #1
0
        public IHttpActionResult FireAlarm(FireAlarm alarm)
        {
            AlarmDomain alarmDomain   = new AlarmDomain();
            DeviceRead  currentDevice = StaticContext.GetCurrentDevice();

            if (currentDevice == null)
            {
                throw new UnauthorizedAccessException("Device token required");
            }

            ValuesDomain valuesDomain = new ValuesDomain();
            DeviceValue  val          = new DeviceValue();

            val          = Utilities.Map <FireAlarm, DeviceValue>(alarm, val);
            val.DeviceId = currentDevice.Id;
            val.AlarmId  = alarm.AlarmId;
            valuesDomain.SaveValue(val);



            if (alarm.Side == "onserver")
            {
                AlarmFireDto alarmDto = new AlarmFireDto();
                alarmDto = Utilities.Map <FireAlarm, AlarmFireDto>(alarm, alarmDto);
                alarmDomain.FireAlarm(alarmDto);
            }
            return(Ok());
        }
Пример #2
0
        public IHttpActionResult SaveValue(string propertyName, DeviceValue value)
        {
            DeviceRead currentDevice = StaticContext.GetCurrentDevice();

            value.DeviceId     = currentDevice.Id;
            value.PropertyName = propertyName;
            ValuesDomain valuesDomain = new ValuesDomain();

            valuesDomain.SaveValue(value);
            return(Ok());
        }