public async Task <IActionResult> Edit(int?id, [Bind("SpellListHasSpellsid,SpellListId,Spellid")] SpellListHasSpells spellListHasSpells) { if (id != spellListHasSpells.SpellListHasSpellsid) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(spellListHasSpells); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpellListHasSpellsExists(spellListHasSpells.SpellListHasSpellsid)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Spellid"] = new SelectList(_context.Set <Spells>(), "Spellsid", "Spellsid", spellListHasSpells.Spellid); ViewData["SpellListId"] = new SelectList(_context.SpellList, "Spelllistid", "Spelllistid", spellListHasSpells.SpellListId); return(View(spellListHasSpells)); }
public async Task <IActionResult> Create([Bind("SpellListHasSpellsid,SpellListId,Spellid")] SpellListHasSpells spellListHasSpells) { if (ModelState.IsValid) { _context.Add(spellListHasSpells); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Spellid"] = new SelectList(_context.Set <Spells>(), "Spellsid", "Spellsid", spellListHasSpells.Spellid); ViewData["SpellListId"] = new SelectList(_context.SpellList, "Spelllistid", "Spelllistid", spellListHasSpells.SpellListId); return(View(spellListHasSpells)); }