public async Task <IActionResult> CastSpell(Spell s) { if (ModelState.IsValid) { // Add logged in user to the model // Note: this null-check allows unit tests to pass with hardcoded user if (s.User == null) { s.User = await userManager.GetUserAsync(User); } // Add spell to the database spellRepo.AddSpell(s); // Redirect user to view their cast spell return(Redirect("Enchantment")); } return(View()); }