public ActionResult AddPlayer()
        {
            var vm = new AddPlayerVM();

            vm.CreateTeamList(_teamRepo.GetTeams());
            vm.CreatePositionList(_playerRepo.GetPositions());

            return(View("AddPlayer", vm));
        }
예제 #2
0
        public IActionResult AddPlayer(AddPlayerVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            rep.AddPlayer(new Player(model.Name, model.TeamId));
            return(RedirectToAction(nameof(Index)));
        }
예제 #3
0
 public IActionResult AddPlayer(AddPlayerVM model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     else
     {
         repHandler.AddPlayer(model);
         return(RedirectToAction(nameof(Index)));
     }
 }
예제 #4
0
        public IActionResult AddPlayer()
        {
            var teams = rep.GetTeams();
            var model = new AddPlayerVM
            {
                TeamDropList = new SelectListItem[teams.Length]
            };

            for (int i = 0; i < teams.Length; i++)
            {
                model.TeamDropList[i] = new SelectListItem {
                    Value = teams[i].Id.ToString(), Text = teams[i].ClassName
                };
            }
            return(View(model));
        }
        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));
            }
        }
예제 #6
0
 internal void AddPlayer(AddPlayerVM model)
 {
     model.TeamId = 3;
     rep.AddPlayer(new Player(model.Name, model.TeamId));
 }