public ActionResult AddPlayer() { var vm = new AddPlayerVM(); vm.CreateTeamList(_teamRepo.GetTeams()); vm.CreatePositionList(_playerRepo.GetPositions()); return(View("AddPlayer", vm)); }
public ActionResult AddPlayer(AddPlayerVM vm) { if (ModelState.IsValid) { var successVM = new AddPlayerSuccessVM(); Player player = _playerRepo.AddPlayer(vm.PlayerToAdd); successVM.PlayerToAdd = player; successVM.Position = _playerRepo.GetPositionByID(vm.PlayerToAdd.PositionID); successVM.Team = _playerRepo.GetTeamByID(vm.PlayerToAdd.TeamID); return(View("AddPlayerSuccess", successVM)); } else { vm.CreateTeamList(_teamRepo.GetTeams()); vm.CreatePositionList(_playerRepo.GetPositions()); return(View("AddPlayer", vm)); } }