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); }
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); }
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 this.View(viewModel); }
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 this.RedirectToAction("EditComputers"); }
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); }