public String ExecuteDeviceCommand(Int32 DeviceCommandId)
        {
            AutomationModelContainer dbe = new AutomationModelContainer();

            DeviceCommand deviceCommand = dbe.DeviceCommands.Single(dc => dc.Id == DeviceCommandId);

            return ExecuteDeviceCommand(deviceCommand);
        }
        public ActionResult ChooseRoom()
        {
            AutomationModelContainer dbe = new AutomationModelContainer();

            ChooseRoomViewModel vm = new ChooseRoomViewModel();

            foreach( Models.Room room in dbe.Rooms )
            {
                vm.AddRoom(room.Id, room.RoomName);
            }

            return View("ChooseRoom", vm);
        }
        public ActionResult AllDeviceCommands()
        {
            AutomationModelContainer dbe = new AutomationModelContainer();
            //MyDatabaseEntities dbe = new MyDatabaseEntities();

            AllDeviceCommandsViewModel vm = new AllDeviceCommandsViewModel();

            foreach (Device device in dbe.Devices)
            {
                foreach (DeviceCommand deviceCommand in device.DeviceCommands)
                    vm.AddDeviceCommand(device.DeviceName, deviceCommand.Id, deviceCommand.Name);
            }

            return View("AllDeviceCommands", vm);
        }
        public String ExecuteRoomActivity(Int32 RoomActivityId)
        {
            AutomationModelContainer dbe = new AutomationModelContainer();

            RoomActivity roomActivity = dbe.RoomActivities.Single(ra => ra.Id == RoomActivityId);

            String result = String.Empty;
            foreach (RequiredCommand rc in roomActivity.RequiredCommands.OrderBy( rc => rc.Sequence ))
            {
                result += String.Format("{0} {1}:", rc.DeviceCommand.Device.DeviceName, rc.DeviceCommand.Name);
                result += ExecuteDeviceCommand(rc.DeviceCommand);
                result += "</br>";
            }

            return result;
        }
        public ActionResult ChooseActivity(Int32 RoomId)
        {
            AutomationModelContainer dbe = new AutomationModelContainer();

            ChooseActivityViewModel vm = new ChooseActivityViewModel();

            Room room = dbe.Rooms.Single(rm => rm.Id == RoomId);

            vm.RoomName = room.RoomName;
            foreach (RoomActivity roomActivitiy in room.RoomActivities)
            {
                vm.AddActivity(roomActivitiy.Id, roomActivitiy.Activity.Activity1);
            }

            return View("ChooseActivity", vm);
        }