Ejemplo n.º 1
0
        //Lara created --- goes to list of Teams page
        public ActionResult Index()
        {
            var ops = new BaseballOperations();
            AddPlayerViewModel teams = new AddPlayerViewModel();

            var response = ops.GetAllTeams();

            return View("Index",response.Teams);
        }
Ejemplo n.º 2
0
        // GET: Player
        public ActionResult AddPlayer()
        {
            BaseballOperations ops = new BaseballOperations();

            AddPlayerViewModel addP = new AddPlayerViewModel();

            var teamResponse = ops.GetAllTeams();
            var positionResponse = ops.GetAllPositions();

            addP.CreatePositionList(positionResponse.Positions);
            addP.CreateTeamList(teamResponse.Teams);

            return View(addP);
        }
Ejemplo n.º 3
0
        public ActionResult AddPlayer(AddPlayerViewModel addP)
        {
            var ops = new BaseballOperations();

            var teamResponse = ops.GetAllTeams();
            var positionResponse = ops.GetAllPositions();

            addP.CreateTeamList(teamResponse.Teams);
            addP.CreatePositionList(positionResponse.Positions);

            if (ModelState.IsValid)
            {
                var playerResponse = ops.CreatePlayer(addP.player);
                playerResponse.Player.Position =
                    ops.GetAllPositions().Positions.FirstOrDefault(p => p.PositionID == addP.player.Position.PositionID);

                return View("PlayerDetails", playerResponse.Player);
            }
            else
            {
                return View(addP);
            }
        }