public void SendSensorSettings(SensorUserEditRCModel sensorRCModel)
        {
            var modelSensor = new
            {
                SetSensor = new Dictionary<string, object>()
            };
            modelSensor.SetSensor.Add("SensorId", sensorRCModel.Id);
            modelSensor.SetSensor.Add("AlarmCheck", sensorRCModel.AlarmCheck);

            if (sensorRCModel.AlarmCheck)
            {
                modelSensor.SetSensor.Add("MinTempAlert", sensorRCModel.MinTempAlert);
                modelSensor.SetSensor.Add("MaxTempAlert", sensorRCModel.MaxTempAlert);
            }
            this.Sender.SendMessageToReceiver(modelSensor, sensorRCModel.ReceiverIp);
        }
        public ActionResult EditSensor(SensorEditViewModel sensorEditViewModel)
        {
            if (ModelState.IsValid)
            {
                var editModel = this.Data.Sensors.All()
                    .Where(s => s.Id == sensorEditViewModel.Id)
                    .Select(s => new
                    {
                        Sensor = s,
                        ReceiverIp = s.Room.Floor.House.ReceiverIp
                    }).SingleOrDefault();
                if (editModel == null)
                {
                    throw new HttpException(500, "No sensor with this Id");
                }
                editModel.Sensor.AlarmCheck = sensorEditViewModel.AlarmCheck;
                editModel.Sensor.MaxTempAlert = sensorEditViewModel.MaxTempAlert;
                editModel.Sensor.MinTempAlert = sensorEditViewModel.MinTempAlert;

                SensorUserEditRCModel sensorUserEditRCModel = new SensorUserEditRCModel
                {
                    Id = editModel.Sensor.ArduinoArraySensorsId,
                    AlarmCheck = editModel.Sensor.AlarmCheck,
                    ReceiverIp = editModel.ReceiverIp,
                    MaxTempAlert = editModel.Sensor.MaxTempAlert,
                    MinTempAlert = editModel.Sensor.MinTempAlert
                };

                using (TransactionScope transaction = new TransactionScope())
                {
                    this.Data.Sensors.Update(editModel.Sensor);
                    this.Data.SaveChanges();

                    this.RemoteControl.SendSensorSettings(sensorUserEditRCModel);
                    transaction.Complete();
                }
                return new HttpStatusCodeResult(200);
            }
            else
            {
                throw new HttpException(500, "The model is invalid");
            }
        }