예제 #1
0
 public void Handle(AddTemperatureDevice message)
 {
     Data.DeviceId = message.DeviceId;
     this.Bus.Publish(new TemperatureDeviceAdded {
         DeviceId = message.DeviceId
     });
     this.Bus.Return(ResultCode.OK);
     Console.WriteLine("AddTemperatureDevice for device id {0}", message.DeviceId);
 }
        public async Task<string> AddTemperature()
        {
            AddTemperatureDevice command = new AddTemperatureDevice
            {
                DeviceId = Guid.NewGuid().ToString()
            };

            int result = await _.Bus.Send(command).Register();

            if (result == ResultCode.OK) return command.DeviceId;

            throw new HttpException((int) HttpStatusCode.BadRequest, "Unable to add device");
        }
        public async Task <string> AddTemperature()
        {
            AddTemperatureDevice command = new AddTemperatureDevice
            {
                DeviceId = Guid.NewGuid().ToString()
            };

            int result = await _.Bus.Send(command).Register();

            if (result == ResultCode.OK)
            {
                return(command.DeviceId);
            }

            throw new HttpException((int)HttpStatusCode.BadRequest, "Unable to add device");
        }