public async Task <IActionResult> Create([Bind("AuthorID,Imie,Nazwisko")] Author author) { if (ModelState.IsValid) { _context.Add(author); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(author)); }
public async Task <IActionResult> Create([Bind("UserID,Imie,Nazwisko,Zapisany_od,Books")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create([Bind("BookID,Tytul,AuthorID,Gatunek")] Book book) { try { if (ModelState.IsValid) { _context.Add(book); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } PopulateAuthorDropdownList(book.Autor); PopulateGatunekDropDownList(book.Gatunek); return(View(book)); }