コード例 #1
0
        public ActionResult EditComputer(String computer)
        {
            var comp      = _BanStorage.GetComputer(computer);
            var ViewModel = new EditComputersViewModel(comp.IpAddress, comp.Room.Name, comp.Banned, comp.CurrentUser);

            return(View(ViewModel));
        }
コード例 #2
0
ファイル: ViewModelsTester.cs プロジェクト: nbl852003/iudico
        public void EditComputersViewModel()
        {
            var editComputersViewModel = new EditComputersViewModel("999.999.888.777", "room1", false, "user1", new List <string>());

            var viewModel = new EditComputersViewModel
            {
                Banned = true, ComputerIP = "888.777.777.888", CurrentUser = "******", Room = "room1"
            };

            Assert.AreEqual(editComputersViewModel.Room, viewModel.Room);
        }
コード例 #3
0
ファイル: ViewModelsTester.cs プロジェクト: nbl852003/iudico
        public void EditComputersViewModel()
        {
            ViewModels.Ban.EditComputersViewModel editComputersViewModel = new EditComputersViewModel("999.999.888.777", "room1", false, "user1");

            EditComputersViewModel viewModel = new EditComputersViewModel
            {
                Banned      = true,
                ComputerIP  = "888.777.777.888",
                CurrentUser = "******",
                Room        = "room1"
            };

            Assert.AreEqual(editComputersViewModel.Room, viewModel.Room);
        }
コード例 #4
0
        public ActionResult EditComputer(EditComputersViewModel viewModel)
        {
            this.BanStorage.EditComputer(viewModel.ComputerIP, viewModel.Banned, viewModel.CurrentUser);

            if (viewModel.Room != "N/A")
            {
                this.BanStorage.AttachComputerToRoom(this.BanStorage.GetComputer(viewModel.ComputerIP), this.BanStorage.GetRoom(viewModel.Room));
            }
            else
            {
                this.BanStorage.DetachComputer(this.BanStorage.GetComputer(viewModel.ComputerIP));
            }

            return(RedirectToAction("EditComputers"));
        }
コード例 #5
0
        public ActionResult EditComputer(string computerIp)
        {
            var computer = this.BanStorage.GetComputer(computerIp);

            var room = this.BanStorage.GetRoom(computer);

            var name = "N/A";

            if (room != null)
            {
                name = room.Name;
            }

            var viewModel = new EditComputersViewModel(computerIp, name, computer.Banned, computer.CurrentUser,
                                                       new List <string> {
                "N/A"
            }.Concat(
                                                           this.BanStorage.GetRooms().Select(r => r.Name)));

            return(View(viewModel));
        }