public async Task <IActionResult> Edit(int id, [Bind("BedrohungId,HeldId,AgressorId,Bedrohungsbezeichnung")] Bedrohung bedrohung) { if (id != bedrohung.BedrohungId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bedrohung); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BedrohungExists(bedrohung.BedrohungId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AgressorId"] = new SelectList(_context.Agressors, "AgressorId", "AgressorEigenschaft", bedrohung.AgressorId); ViewData["HeldId"] = new SelectList(_context.Helds, "HeldId", "HeldEigenschaft", bedrohung.HeldId); return(View(bedrohung)); }
public async Task <IActionResult> Create([Bind("BedrohungId,HeldId,AgressorId,Bedrohungsbezeichnung")] Bedrohung bedrohung) { if (ModelState.IsValid) { _context.Add(bedrohung); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AgressorId"] = new SelectList(_context.Agressors, "AgressorId", "AgressorEigenschaft", bedrohung.AgressorId); ViewData["HeldId"] = new SelectList(_context.Helds, "HeldId", "HeldEigenschaft", bedrohung.HeldId); return(View(bedrohung)); }