public async Task <IActionResult> Edit(int id, [Bind("Id,VehicleModel,Registration,Owner,Apartment")] Vehicle vehicle) { if (id != vehicle.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vehicle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleExists(vehicle.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vehicle)); }
public async Task <IActionResult> Edit(int id, [Bind("PermitId,VehicleId,PermitStartDate,PermitEndDate,Valid,Fee,Premium")] Permit permit) { if (id != permit.PermitId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(permit); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PermitExists(permit.PermitId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["VehicleId"] = new SelectList(_context.Vehicle, "Id", "Id", permit.VehicleId); return(View(permit)); }