public async Task <IActionResult> Edit(int id, [Bind("Date,Technician,PrinterId,LocationId,Id,Name")] Maintenance maintenance) { if (id != maintenance.Id) { return(RedirectToAction(nameof(Index))); } if (ModelState.IsValid) { try { _context.Update(maintenance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MaintenanceExists(maintenance.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LocationId"] = new SelectList(_context.Location, "Id", "Id", maintenance.LocationId); ViewData["PrinterId"] = new SelectList(_context.Printer, "Id", "Id", maintenance.PrinterId); return(View(maintenance)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Location location) { if (id != location.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(location); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationExists(location.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(location)); }
public async Task <IActionResult> Edit(int id, [Bind("Brand,Model,PrinterType,Serial,PersonInCharge,LocationId,Id,Name")] Printer printer) { if (id != printer.Id) { return(RedirectToAction(nameof(Index))); } if (ModelState.IsValid) { try { _context.Update(printer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrinterExists(printer.Id)) { return(RedirectToAction(nameof(Index))); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LocationId"] = new SelectList(_context.Set <Location>(), "Id", "Id", printer.LocationId); return(View(printer)); }