public async Task <IActionResult> Add(VideoGame game) { if (ModelState.IsValid) { //Add to database await VideoGameDB.AddAsync(game, _context); return(RedirectToAction("Index")); } //Return view with model including error messages return(View(game)); }
public async Task <IActionResult> Add(VideoGame game) { if (ModelState.IsValid) { // Add to Database (await must be called before you call an async method) await VideoGameDB.AddAsync(game, context); return(RedirectToAction("Index")); } ; // So that all of the errors that you encounter are sent with the view return(View(game)); }