public async Task <IActionResult> Edit(int id, [Bind("NetworkAdepterId,deviceId,MACAddress")] NetworkAdepter networkAdepter) { if (id != networkAdepter.NetworkAdepterId) { return(NotFound()); } if (ModelState.IsValid) { networkAdepter.MACAddress = networkAdepter.MACAddress.ToUpper().Replace(":", "-"); try { _context.Update(networkAdepter); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NetworkAdepterExists(networkAdepter.NetworkAdepterId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["deviceId"] = new SelectList(_context.Device, "deviceId", "contractNo", networkAdepter.deviceId); return(View(networkAdepter)); }
public async Task <IActionResult> Create([Bind("NetworkAdepterId,deviceId,MACAddress")] NetworkAdepter networkAdepter) { if (ModelState.IsValid) { networkAdepter.MACAddress = networkAdepter.MACAddress.ToUpper().Replace(":", "-"); _context.Add(networkAdepter); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["deviceId"] = new SelectList(_context.Device, "deviceId", "contractNo", networkAdepter.deviceId); return(View(networkAdepter)); }