public async Task <IActionResult> Create([Bind("Id,BestellingId,GerechtId,Aantal,Opmerkingen")] BesteldGerecht besteldGerecht) { if (ModelState.IsValid) { _context.Add(besteldGerecht); await _context.SaveChangesAsync(); // Terug naar de bestelling waarvan dit bestelde gerecht deel uitmaakt. return(RedirectToAction( nameof(BestellingController.Edit), nameof(BestellingController).Replace("Controller", ""), new { id = besteldGerecht.BestellingId })); } else { ViewData["BestellingId"] = new SelectList( _context.Bestellingen, nameof(Bestelling.Id), nameof(Bestelling.Id), besteldGerecht.BestellingId); ViewData["GerechtId"] = new SelectList( FilterEnSorteerGerechten(besteldGerecht.BestellingId, null).Select(g => new { Id = g.Id, SamengesteldeNaam = $"{g.Categorie} - {g.Naam}" }), "Id", "SamengesteldNaam", besteldGerecht.GerechtId); return(View(besteldGerecht)); } }
public async Task <IActionResult> Create([Bind("Id,Naam,StraatEnNummer,Postcode,Woonplaats,Telefoonnummer,Email,Opmerkingen")] Klant klant) { if (ModelState.IsValid) { _context.Add(klant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(klant)); }
public async Task <IActionResult> Create([Bind("Id,Categorie,Naam,Omschrijving,Prijs")] Gerecht gerecht) { if (ModelState.IsValid) { _context.Add(gerecht); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(gerecht)); }
public async Task <IActionResult> Create([Bind("Id,Status,Betaald,KlantId,Tijdslot,Opmerkingen")] Bestelling bestelling) { await ControleerWijzigingen(null, bestelling); if (ModelState.IsValid) { _context.Add(bestelling); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Edit), new { id = bestelling.Id })); } else { ViewData["KlantId"] = new SelectList(_context.Klanten, "Id", "Email", bestelling.KlantId); return(View(bestelling)); } }