Beispiel #1
0
 public PlayerInTeam( Team team , Player player, int year )
     : base()
 {
     this.teamId = team.Id;
     this.playerId = player.Id;
     this.year = year;
 }
        public ActionResult Index(Guid playerId, string gender)
        {
            Player player;
            Dictionary<string, string> playerDict;
            List<Dictionary<string, string>> gamesDict;
            List<Dictionary<string, string>> teamsDict;
            List<Game> gamesWithReward;
            List<Team> teamsList;
            Middleware.VolleyballService.VolleyballServiceClient client;

            gamesWithReward = new List<Game>();
            teamsList = new List<Team>();
            client = new Middleware.VolleyballService.VolleyballServiceClient();
            playerDict = client.Read(playerId, Middleware.VolleyballService.TablesNames.Players);
            gamesDict = client.ReadPlayerStatisticsInGames(playerId, Middleware.VolleyballService.PlayersInfo.BestPlayer);
            teamsDict = client.ReadTeams_Player(playerId);
            player = new Player(playerDict);

            if (gamesDict != null)
            {
                foreach (var item in gamesDict)
                {
                    gamesWithReward.Add(new Game(item));
                }
            }

            foreach (var item in teamsDict)
            {
                teamsList.Add(new Team(item));
            }

            if (!string.IsNullOrEmpty(gender))
            {
                ViewBag.gender = gender;
            }
            return View(new PlayerInformationModel(player, teamsList, gamesWithReward));
        }
Beispiel #3
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            bool succededHeightParse;
            bool succededNumberParse;
            string path;
            bool isCaptain;
            string name;
            string playerAmplua;
            int number;
            bool validated;
            string stringNumber;
            int selectedTeamIndex;
            bool isDuplicated;
            string filepath;
           
            int age;
            int height;
            Player player;

            path = imagePath.Text;
            name = playerName.Text.Trim().ToUpper();
            playerAmplua = amplua.Text;


            stringNumber = playerNumber.Text.Trim();
            isCaptain = captainSign.IsChecked.Value;
            selectedTeamIndex = teamsCombobox.SelectedIndex;
            succededHeightParse = Int32.TryParse(playerHeight.Text, out height);
            succededNumberParse = Int32.TryParse(stringNumber, out number);

            validated = ValidatePlayer(name, stringNumber, playerAmplua, league, path, playerHeight.Text, playerAge.SelectedValue);

            if (validated)
            {
                age = (int)playerAge.SelectedValue;
                Int32.TryParse(playerHeight.Text, out height);
                Int32.TryParse(stringNumber, out number);

                if (team == null)
                {
                    isDuplicated = client.IsIdentifiedDuplicate(number, listOfTeams[selectedTeamIndex].Id, isCaptain);
                }
                else
                {
                    if (isCaptain)
                    {
                        isDuplicated = playersList.Any(pl => pl.Number == number || pl.Captain == true);
                    }
                    else
                    {
                        isDuplicated = playersList.Any(pl => pl.Number == number);
                    }
                }
                if (!isDuplicated)
                {
                    try
                    {
                        baseDirectoryPath = AppDomain.CurrentDomain.BaseDirectory;
                        baseDirectoryToCombine = baseDirectoryPath.Remove(baseDirectoryPath.Length - 21, 21);
                        string guidToDB = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(openFileDlg.FileName);
                        filepath = baseDirectoryToCombine + "VolleyballMvc\\Content\\Images\\" + guidToDB;
                        File.Copy(System.IO.Path.GetFullPath(path), filepath);
                        player = new Player(name, number, playerAmplua, isCaptain, league, guidToDB, age, height);

                        if (team == null)
                        {
                            var plInTeam = new PlayerInTeam(listOfTeams[teamsCombobox.SelectedIndex], player, DateTime.Now.Year);
                            var playerDict = player.ConvertInstanceToDictionary();
                            var plInTeamDict = plInTeam.ConvertInstanceToDictionary();

                            client.Insert(playerDict, Middleware.VolleyballService.TablesNames.Players);
                            client.Insert(plInTeamDict, Middleware.VolleyballService.TablesNames.PlayerInTeams);
                        }
                        else
                        {
                            playersList.Add(player);
                        }
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("Unable to save file " + exp.Message);

                    }
                    ClearInputInfo();
                    this.Visibility = Visibility.Hidden;
                }
                else
                {
                    MessageBox.Show("Please check inserted information.");
                }
            }
        }
Beispiel #4
0
        public void SetPlayerInfo(Player player)
        {
            playerName.Text = player.Name;
            playerNumber.Text = player.Number.ToString();
            amplua.Text = player.Amplua;

            if (player.Captain)
            {
                captainSign.IsChecked = true;
            }
            if (player.League == "female")
            {
                RadioButtonFemale.IsChecked = true;
            }
            else
            {
                RadioButtonMale.IsChecked = true;
            }
            playerToUpdate = player;

            saveButton.Visibility = Visibility.Collapsed;
            updateButton.Visibility = Visibility.Visible;
        }