Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ImageName,Title,Active,UrlName,HardwareComponentId")] HardwareUnit hardwareUnit)
        {
            if (id != hardwareUnit.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hardwareUnit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HardwareUnitExists(hardwareUnit.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HardwareComponentId"] = new SelectList(_context.HardwareComponents, "ID", "Name", hardwareUnit.HardwareComponentId);
            return(View(hardwareUnit));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,ImageName,Title,Active,UrlName,HardwareComponentId")] HardwareUnit hardwareUnit)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hardwareUnit);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HardwareComponentId"] = new SelectList(_context.HardwareComponents, "ID", "Name", hardwareUnit.HardwareComponentId);
            return(View(hardwareUnit));
        }