public IActionResult AddPlayersByCoach(AddPlayersViewModel viewModel) { if (ModelState.IsValid) { Player player = new Player(viewModel.FirstName, viewModel.LastName, viewModel.Position); iPlayerRepo.AddPlayerAsync(player).Wait(); //Find players team coachid string coachID = User.FindFirst(ClaimTypes.NameIdentifier).Value; int playerID = player.ID; int teamID = iTeamRepo.FindTeamIDByCoach(coachID); /* * TeamPlayer teamPlayer = new TeamPlayer(viewModel.startDate, player.ID, team.TeamID); * database.TeamPlayers.Add(teamPlayer); * database.SaveChanges(); */ iTeamPlayerRepo.AddTeamPlayer(viewModel.startDate, playerID, teamID).Wait(); return(RedirectToAction("SearchPlayers")); }//END OF IF STATEMENT else { PopulateDropDownLists(); return(View("~/Views/Players/AddPlayers.cshtml")); } //must have add player working and tested //ALSO create findTeamHelper() //Create TeamPlayerRepo }