public async Task <IActionResult> Edit(int id, [Bind("Id,AttributeValue,ShortInfo,FilterComponentId,HardwareUnitId,ComponentSpecificationId")] HardwareUnitSpecification hardwareUnitSpecification) { if (id != hardwareUnitSpecification.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hardwareUnitSpecification); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HardwareUnitSpecificationExists(hardwareUnitSpecification.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ComponentSpecificationId"] = new SelectList(_context.ComponentSpecifications, "ID", "AttributeName", hardwareUnitSpecification.ComponentSpecificationId); ViewData["FilterComponentId"] = new SelectList(_context.FilterComponents, "ID", "Name", hardwareUnitSpecification.FilterComponentId); ViewData["HardwareUnitId"] = new SelectList(_context.HardwareUnits, "Id", "Title", hardwareUnitSpecification.HardwareUnitId); return(View(hardwareUnitSpecification)); }
public async Task <IActionResult> Create([Bind("Id,AttributeValue,ShortInfo,FilterComponentId,HardwareUnitId,ComponentSpecificationId")] HardwareUnitSpecification hardwareUnitSpecification) { if (ModelState.IsValid) { _context.Add(hardwareUnitSpecification); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ComponentSpecificationId"] = new SelectList(_context.ComponentSpecifications, "ID", "AttributeName", hardwareUnitSpecification.ComponentSpecificationId); ViewData["FilterComponentId"] = new SelectList(_context.FilterComponents, "ID", "Name", hardwareUnitSpecification.FilterComponentId); ViewData["HardwareUnitId"] = new SelectList(_context.HardwareUnits, "Id", "Title", hardwareUnitSpecification.HardwareUnitId); return(View(hardwareUnitSpecification)); }