public Response<Player> CreatePlayer(Player player)
        {
            var response = new Response<Player>();
            var players = _repo.GetAllPlayersByTeam(player.TeamID);

            try
            {
                foreach (var p in players)
                {
                    if (player.PlayerName == p.PlayerName)
                    {
                        response.Success = false;
                        response.Message = "That player already exists!";
                        return response;
                    }
                }
                _repo.CreatePlayer(player);
                response.Success = true;
                response.Message = "Successfully created player";
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return response;
        }
        public ActionResult PlayerConfirm(Player player)
        {
            if (ModelState.IsValid)
            {
                var response = _manager.CreatePlayer(player);

                return View();
            }
            return View("NewPlayer");
        }
        public void CreatePlayer(Player player)
        {
            using (var context = new Models.BaseballLeagueEntities())
            {
                Models.Player newPlayer = new Models.Player();
                newPlayer.PlayerName = player.PlayerName;
                newPlayer.JerseyNumber = (byte)player.JerseyNumber;
                newPlayer.Position = player.Position;
                newPlayer.BattingAverage =(decimal.Round(player.BattingAverage.Value, 3));
                newPlayer.YearsPlayed = (byte)player.YearsPlayed;
                newPlayer.TeamID = player.TeamID;

                context.Players.Add(newPlayer);
                context.SaveChanges();
            }
        }
 private Player MapPlayer(Models.Player from)
 {
     var to = new Player();
     to.BattingAverage = (decimal.Round(from.BattingAverage.Value, 3));
     to.JerseyNumber = from.JerseyNumber;
     to.PlayerID = from.PlayerID;
     to.PlayerName = from.PlayerName;
     to.Position = from.Position;
     to.TeamID = from.TeamID;
     to.YearsPlayed = from.YearsPlayed;
     return to;
 }