public async Task <IActionResult> Create([Bind("Author,Publisher,Published,ISBN,ProductId,Title,Price,ImageUrl,Category,CreatedDate")] Book book) { if (ModelState.IsValid) { _context.Add(book); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(book)); }
public async Task <IActionResult> Create([Bind("Artist,Label,Released,ProductId,Title,Price,ImageUrl,Category")] MusicCD musicCD) { if (ModelState.IsValid) { _context.Add(musicCD); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(musicCD)); }
public async Task <IActionResult> Create([Bind("Director,Released,ProductId,Title,Price,ImageUrl,Category,CreatedDate")] Movie movie) { if (ModelState.IsValid) { _context.Add(movie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> Create([Bind("Artist,Label,Released,Title,Price,ImageUrl,Category")] MusicCD musicCD) { try { if (ModelState.IsValid) { _context.Add(musicCD); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(musicCD)); }