public async Task <IActionResult> Edit(int id, [Bind("Id,AutherId,BookId")] AutherBook autherBook) { if (id != autherBook.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(autherBook); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AutherBookExists(autherBook.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AutherId"] = new SelectList(_context.Auther, "Id", "Name", autherBook.AutherId); ViewData["BookId"] = new SelectList(_context.Book, "Id", "Des", autherBook.BookId); return(View(autherBook)); }
public async Task <IActionResult> Create([Bind("Id,AutherId,BookId")] AutherBook autherBook) { if (ModelState.IsValid) { autherBook.CreateAt = DateTime.Now; _context.Add(autherBook); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AutherId"] = new SelectList(_context.Auther, "Id", "Name", autherBook.AutherId); ViewData["BookId"] = new SelectList(_context.Book, "Id", "Des", autherBook.BookId); return(View(autherBook)); }