public async Task <IActionResult> Edit(int id, [Bind("PrinterId,IP,Localisation,SerialNumber,Photo,Info,Person,Status,PrinterType")] Printer printer) { if (id != printer.PrinterId) { return(NotFound()); } printer.PrinterType = _context .PrinterTypes .SingleOrDefault(a => a.PrinterTypeId == printer.PrinterType.PrinterTypeId); if (ModelState.IsValid) { try { _context.Update(printer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrinterExists(printer.PrinterId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(printer)); }
public async Task <IActionResult> Edit(int id, PrinterAccessory accessory) { if (ModelState.IsValid) { try { _context.Update(accessory); //TODO: Notify registry about this update await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccessoryExists(accessory.PrinterAccessoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Index))); }