Пример #1
0
        public void BanComputerViewModelTest()
        {
            var computers = new List<Computer> {
                    new Computer { Banned = false, CurrentUser = "******", IpAddress = "999.998.997.996" }, 
                    new Computer { Banned = true, CurrentUser = "******", IpAddress = "889.888.887.886" }
                };

            var banComputerViewModel = new BanComputerViewModel { Computers = computers };

            Assert.AreEqual(2, banComputerViewModel.Computers.Count);

            Assert.True(banComputerViewModel.Computers.Count(c => c.Banned) == 1);
        }
Пример #2
0
        public ActionResult EditComputers()
        {
            var computers = this.BanStorage.GetComputers().ToList();

            var attachments = this.BanStorage.GetRoomAttachments().ToList();

            var list = new List<ComputerWithAttachmentViewModel>();

            foreach (var computer in computers)
            {
                if (attachments.SingleOrDefault(a => a.ComputerIp == computer.IpAddress) != null)
                {
                    var roomId = attachments.SingleOrDefault(a => a.ComputerIp == computer.IpAddress).RoomId;

                    var roomName = this.BanStorage.GetRoom(roomId).Name;

                    list.Add(new ComputerWithAttachmentViewModel { Computer = computer, RoomName = roomName });
                }

                else
                {
                    list.Add(new ComputerWithAttachmentViewModel { Computer = computer });
                }
            }

            var viewModel = new BanComputerViewModel { Computers = list };

            return this.View(viewModel);
        }
Пример #3
0
        public ActionResult BanComputer()
        {
            var viewModel = new BanComputerViewModel();
            viewModel.Computers = _BanStorage.GetComputers().ToList();

            return View(viewModel);
        }