public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,Age,SkillLevel,Email")] Player player) { //Validate the information, and save only if valid if (ModelState.IsValid) { detailsPlayerContext.Add(player); await detailsPlayerContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index), "Home")); } //Information not valid, return to Add Player page return(View(player)); }
public void Post(Player player) { try { Console.WriteLine("test3"); var context = new PingPongContext(); Console.WriteLine("test1"); // save new player context.Add(player); Console.WriteLine("test2"); context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.ToString()); } }