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