Пример #1
0
 public ActionResult Index()
 {
     return(View(_computerService.GetAllComputers().Select(computer => new ComputerViewModel
     {
         Id = computer.ComputerId,
         Name = computer.Name,
         Room = computer.RoomNumber,
         IpAddress = IpAddressHelper.ConvertIpAddressToString(computer.IpAddress),
         NetworkAddress = IpAddressHelper.ConvertIpAddressToString(computer.NetworkAddress),
         NetworkMask = IpAddressHelper.ConvertIpAddressToString(computer.SubnetAddress)
     }).ToList()));
 }
Пример #2
0
        public ActionResult Edit(long id)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index", "Error"));
            }
            var entity = _computerService.GetComputerById(id);

            if (entity == null)
            {
                return(RedirectToAction("Index", "Error"));
            }
            var model = new ComputerEditViewModel
            {
                Id             = entity.ComputerId,
                RoomNumber     = entity.RoomNumber.ToString(),
                IpAddress      = IpAddressHelper.ConvertIpAddressToString(entity.IpAddress),
                NetworkAddress = IpAddressHelper.ConvertIpAddressToString(entity.NetworkAddress),
                NetworkMask    = IpAddressHelper.ConvertIpAddressToString(entity.SubnetAddress),
                Name           = entity.Name
            };

            return(View(model));
        }