Exemplo n.º 1
0
        public ActionResult EditRoom()
        {
            var viewModel = new RoomsViewModel();
            viewModel.Rooms = _BanStorage.GetRooms().Select(i => i.Name).ToList();

            return View(viewModel);
        }
Exemplo n.º 2
0
        public void RoomsViewModelTest()
        {
            var rooms = new List<string> { "room1", "room2", "room3" };
            var computers = new List<string> { "computer1", "computer2", "computer3", "computer4" };
            var unchosenComputers = new List<string> { "comuter3" };
            const string CurrentRoom = "room1";

            var roomsViewModel = new RoomsViewModel
                {
                    Computers = computers, 
                    CurrentRoom = CurrentRoom, 
                    Rooms = rooms, 
                    UnchoosenComputers = unchosenComputers
                };

            Assert.AreEqual(3, roomsViewModel.Rooms.Count);
            Assert.True(roomsViewModel.Rooms.Contains("room2"));
            Assert.AreEqual(4, roomsViewModel.Computers.Count);
            Assert.False(roomsViewModel.Computers.Contains("computer9"));
        }
Exemplo n.º 3
0
        public ActionResult EditRoom(string currentRoom)
        {
            var attachments = this.BanStorage.GetRoomAttachments();

            var viewModel = new RoomsViewModel
                                {
                                    CurrentRoom = currentRoom,
                                    Rooms = this.BanStorage.GetRooms().Select(i => i.Name).ToList(),
                                    Computers = this.BanStorage.GetComputers().Select(c => c.IpAddress).ToList()
                                };
            viewModel.UnchoosenComputers = viewModel.Computers.Where(c => attachments.Count(a => a.ComputerIp == c) == 0).ToList();

            return View(viewModel);
        }
Exemplo n.º 4
0
        public ActionResult EditRoom()
        {
            var viewModel = new RoomsViewModel { Rooms = this.BanStorage.GetRooms().Select(i => i.Name).ToList() };

            return this.View(viewModel);
        }
Exemplo n.º 5
0
        public ActionResult EditRoom(String CurrentRoom)
        {
            var viewModel = new RoomsViewModel();
            viewModel.CurrentRoom = CurrentRoom;
            viewModel.Rooms = _BanStorage.GetRooms().Select(i => i.Name).ToList();
            viewModel.Computers = _BanStorage.GetRoom(CurrentRoom).Computers.Select(c => c.IpAddress).ToList();
            viewModel.UnchoosenComputers = _BanStorage.GetComputers().Where(i => i.Room == null).Select(x => x.IpAddress).ToList();

            return View(viewModel);
        }
Exemplo n.º 6
0
        public ActionResult EditRoom(RoomsViewModel Model)
        {
            var room = new Room();
            room = _BanStorage.GetRoom(Model.CurrentRoom);
            foreach(String comp in Model.Computers)
            {
                var computer = _BanStorage.GetComputer(comp);
                if (computer.Room == null)
                    _BanStorage.AttachComputerToRoom(computer, room);
            }

            foreach (String comp in Model.UnchoosenComputers)
            {
                var computer = _BanStorage.GetComputer(comp);
                if (computer.Room != null)
                    _BanStorage.DetachComputer(computer);
            }
            return View(Model);
        }