public async Task <IActionResult> Create([Bind("Name")] Author author) { if (ModelState.IsValid) { _context.Add(author); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(author)); }
public async Task <IActionResult> Create([Bind("Title,AuthorID,LanguageID")] Book book) { if (ModelState.IsValid) { _context.Add(book); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Languages = new SelectList(_context.Languages.AsNoTracking(), "ID", nameof(Language.Name), book.LanguageID); ViewBag.Authors = new SelectList(_context.Authors.AsNoTracking(), "ID", nameof(Author.Name), book.AuthorID); return(View(book)); }