Exemplo n.º 1
0
        // GET: RaspberryController/Edit/5
        public ActionResult Edit(Guid id)
        {
            var entity = _context.Raspberrys.Find(id);
            RaspberryEditViewModel viewModel = new RaspberryEditViewModel()
            {
                RaspberryId = entity.RaspberryId,
                IPadress    = entity.IPadress,
                Location    = entity.location,
                Name        = entity.Name
            };

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public ActionResult SaveRaspberryChange(RaspberryEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Edit", model));
            }

            var entity = _context
                         .Raspberrys
                         .Find(
                model.RaspberryId);

            entity.Name     = model.Name;
            entity.location = model.Location;
            entity.IPadress = model.IPadress;

            _context.Raspberrys.Update(entity);
            _context.SaveChanges();

            return(RedirectToAction(nameof(Index)));
        }