public ActionResult DeleteConfirmed(int id)
        {
            var deleteModel = this.Data.Sensors.All()
                .Where(t => t.Id == id)
                .Select(s => new
            {
                ReceiverIp = s.Room.Floor.House.ReceiverIp,
                SensorId = s.Id,
                SensorIdInArray = s.ArduinoArraySensorsId,
                Thermostat = s.Room.Thermostat,
                Room = s.Room,
            }).SingleOrDefault();
            if (deleteModel == null)
            {
                return HttpNotFound();
            }
            SensorDeleteRCModel sensorDeleteRCModel = new SensorDeleteRCModel
            {
                Id = deleteModel.SensorIdInArray,
                ReceiverIp = deleteModel.ReceiverIp
            };

            using (TransactionScope transaction = new TransactionScope())
            {
                ThermostatDeleteRCModel thermostatDeleteRCModel = null;
                if (deleteModel.Room.ThermostatId != null)
                {
                    thermostatDeleteRCModel = new ThermostatDeleteRCModel
                    {
                        Id = deleteModel.Thermostat.ArduinoArrayTermostatId,
                        ReceiverIp = deleteModel.ReceiverIp
                    };
                    this.Data.Thermostats.Delete(deleteModel.Room.ThermostatId.Value);
                }
                this.Data.Sensors.Delete(deleteModel.SensorId);
                this.Data.SaveChanges();

                if (thermostatDeleteRCModel != null)
                {
                    this.RemoteControl.SendThermostatDelete(thermostatDeleteRCModel);
                }
                this.RemoteControl.SendSensorDelete(sensorDeleteRCModel);
                transaction.Complete();
            }

            return RedirectToAction("RoomDetails", "Rooms", new { RoomId = deleteModel.Room.Id });
        }
 public void SendThermostatDelete(ThermostatDeleteRCModel thermostatDeleteRCModel)
 {
     this.Sender.SendMessageToReceiver(new
     {
         SetDeleteThermostat = new
         {
             TermostatId = thermostatDeleteRCModel.Id,
         }
     }, thermostatDeleteRCModel.ReceiverIp);
 }