Exemplo n.º 1
0
        public IActionResult Edit(NewDeviceEditViewModel model)
        {
            //Check to see that the device exists
            var device = context.Devices.Find(model.Id);

            if (device == null || !ModelState.IsValid)
            {
                return(View());
            }
            //update device and save changes
            device.CustomerId      = model.CustomerId;
            device.Make            = model.Make;
            device.ModelNumber     = model.ModelNumber;
            device.OperatingSystem = model.OperatingSystem;
            device.Password        = model.Password;
            device.Serviced        = model.Serviced;
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public IActionResult Edit(int deviceId)
        {
            //Check to see if device exists
            var device = context.Devices.Find(deviceId);

            if (device == null)
            {
                return(View());
            }
            //create new DeviceEditViewModel
            NewDeviceEditViewModel model = new NewDeviceEditViewModel
            {
                Id              = device.Id,
                CustomerId      = device.CustomerId,
                Make            = device.Make,
                ModelNumber     = device.ModelNumber,
                OperatingSystem = device.OperatingSystem,
                Password        = device.Password,
                Serviced        = device.Serviced
            };

            //return model
            return(View(model));
        }