public async Task <IActionResult> Edit(int id, [Bind("VehicleId,UserId,Make,Model,Year,ColourId,Plate,Image")] Vehicle vehicle) { if (id != vehicle.VehicleId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vehicle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleExists(vehicle.VehicleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ColourId"] = new SelectList(_context.Colour, "ColourId", "Colour1", vehicle.ColourId); ViewData["UserId"] = new SelectList(_context.User, "UserId", "Email", vehicle.UserId); return(View(vehicle)); }
public async Task <IActionResult> Edit(int id, [Bind("UserId,FirstName,LastName,Username,Email,Image,LicenceClassId,Experience")] User user) { if (id != user.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LicenceClassId"] = new SelectList(_context.LicenceClass, "LicenceClassId", "LicenceClass1", user.LicenceClassId); return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("PostId,StatusId,DriverId,Destination,Location,Date,Time")] Post post) { if (id != post.PostId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(post); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(post.PostId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DriverId"] = new SelectList(_context.User, "UserId", "Email", post.DriverId); ViewData["StatusId"] = new SelectList(_context.PostStatus, "PostStatusId", "Status", post.StatusId); return(View(post)); }