public async Task <IActionResult> Edit(int id, [Bind("ThemeId,AuthorId")] ThemeAuthor themeAuthor) { if (id != themeAuthor.ThemeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(themeAuthor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThemeAuthorExists(themeAuthor.ThemeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AuthorId"] = new SelectList(_context.Author, "Id", "LastName", themeAuthor.AuthorId); ViewData["ThemeId"] = new SelectList(_context.Theme, "Id", "Name", themeAuthor.ThemeId); return(View(themeAuthor)); }
public async Task <IActionResult> Create([Bind("ThemeId,AuthorId")] ThemeAuthor themeAuthor) { if (ModelState.IsValid) { _context.Add(themeAuthor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AuthorId"] = new SelectList(_context.Author, "Id", "LastName", themeAuthor.AuthorId); ViewData["ThemeId"] = new SelectList(_context.Theme, "Id", "Name", themeAuthor.ThemeId); return(View(themeAuthor)); }