Esempio n. 1
0
 public PlayerDto(Player player)
     : base(player)
 {
     FirstName = player.FirstName;
     LastName = player.LastName;
     TeamId = player.TeamId;
     Attack = player.Attack;
     Pass = player.Pass;
     Defense = player.Defense;
     PlayerPosition = player.PlayerPosition.ToString();
     Height = player.Height;
     Weight = player.Weight;
     Age = player.Age;
     FavouriteFoot = player.FavouriteFoot.ToString();
     Price = player.Price;
 }
        private double CalculatePrice(Player player)
        {
            double price = 0.0;
            int playerRate = player.GetPlayerRate();

            if(playerRate < 20)
            {
                price = 100000.0;
            }
            else if(playerRate >= 20 && playerRate < 25)
            {
                price = 300000.0;
            }
            else if(playerRate >= 25 && playerRate < 30)
            {
                price = 800000.0;
            }
            else if(playerRate >= 30 && playerRate < 35)
            {
                price = 1300000.0;
            }
            else if(playerRate >= 35 && playerRate < 40)
            {
                price = 1800000.0;
            }
            else if(playerRate >= 40 && playerRate < 45)
            {
                price = 2400000.0;
            }
            else if(playerRate >= 45 && playerRate < 50)
            {
                price = 2400000.0;
            }
            else if(playerRate >= 50 && playerRate < 55)
            {
                price = 3200000.0;
            }
            else if(playerRate >= 55 && playerRate < 60)
            {
                price = 4000000.0;
            }
            else if(playerRate >= 60 && playerRate < 65)
            {
                price = 6000000.0;
            }
            else if(playerRate >= 65 && playerRate < 70)
            {
                price = 9000000.0;
            }
            else if(playerRate >= 70 && playerRate < 75)
            {
                price = 13000000.0;
            }
            else if(playerRate >= 75 && playerRate < 80)
            {
                price = 20000000.0;
            }
            else if(playerRate >= 80 && playerRate < 85)
            {
                price = 30000000.0;
            }
            else if(playerRate >= 85 && playerRate < 90)
            {
                price = 45000000.0;
            }
            else if(playerRate >= 90 && playerRate < 95)
            {
                price = 70000000.0;
            }
            else if(playerRate >= 95 && playerRate < 100)
            {
                price = 100000000.0;
            }

            return price;
        }
 public void Update(Player player)
 {
     _playerRepository.Update(player);
 }
 public Player Create(Player player)
 {
     return _playerRepository.Create(player);
 }
        private void CreatePlayerData(Team team, PlayerPositionEnum playerPosition)
        {
            Random random = new Random();

            if(playerPosition == PlayerPositionEnum.Unknown)
            {
                int randomPosition = random.Next(1, 12);
                playerPosition = (PlayerPositionEnum) randomPosition;
            }

            int randomFoot = random.Next(1, 2);
            FavouriteFootEnum favouriteFoot = (FavouriteFootEnum) randomFoot;

            var player = new Player
            {
                FirstName = "John",
                LastName = "Smith",
                Team = team,
                TeamId = team.Id,
                PlayerPosition = playerPosition,
                FavouriteFoot = favouriteFoot,
                Attack = GenerateAttackPoints(playerPosition),
                Pass = GeneratePassPoints(playerPosition),
                Defense = GenerateDefensePoints(playerPosition),
                Age = random.Next(17, 23),
                Height = random.Next(150, 200),
                Weight = random.Next(60, 100)
            };

            team.Attack += player.Attack;
            team.Defense += player.Defense;
            team.Pass += player.Pass;

            player.Price = CalculatePrice(player);
            _playerRepository.Create(player);
        }