public async Task <IActionResult> Edit(int id, EditBestellingViewModel viewModel) { if (id != viewModel.Bestelling.BestellingID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(viewModel.Bestelling); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BestellingExists(viewModel.Bestelling.BestellingID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } viewModel.Klanten = new SelectList(_context.Klanten, "KlantID", "Naam", viewModel.Bestelling.KlantID); return(View(viewModel)); }
// GET: Bestelling/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } EditBestellingViewModel viewModel = new EditBestellingViewModel(); viewModel.Bestelling = await _context.Bestellingen.FindAsync(id); if (viewModel.Bestelling == null) { return(NotFound()); } viewModel.Bestelling.PersoonID = viewModel.Persoon.Persoon_ID; return(View(viewModel)); }
//Bewerken (bestelling) //GET public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } EditBestellingViewModel viewModel = new EditBestellingViewModel(); viewModel.Bestelling = await _context.Bestellingen.FindAsync(id); if (viewModel.Bestelling == null) { return(NotFound()); } viewModel.Klanten = new SelectList(_context.Klanten, "KlantID", "VolledigeNaam", viewModel.Bestelling.KlantID); return(View(viewModel)); }