Exemple #1
0
        private void AddNewMatch()
        {
            var viewModelAddNewMatch = new ViewModelAddNewMatch {
                ListOfUsers = ListOfUsers, ListOfClubs = ListOfClubs
            };
            var addNewMatchWindow = new AddNewMatchWindow(viewModelAddNewMatch);

            viewModelAddNewMatch.ListOfTypeMatches.Add(new TypeMatch());
            foreach (var tournament in ListOfTournaments)
            {
                viewModelAddNewMatch.ListOfTypeMatches.Add(new TypeMatch(tournament.Name, tournament.Factor));
                if (tournament.IsWorldCup)
                {
                    viewModelAddNewMatch.ListOfTypeMatches.Add(new TypeMatch(tournament.Name + " - Финал", tournament.Factor));
                }
            }
            addNewMatchWindow.ShowDialog();
            if (addNewMatchWindow.DialogResult == true)
            {
                var lFirst = new ObservableCollection <int>();
                foreach (var player in viewModelAddNewMatch.ListOfGoalsFirstUser)
                {
                    lFirst.Add(player.Id);
                }
                var lSecond = new ObservableCollection <int>();
                foreach (var player in viewModelAddNewMatch.ListOfGoalsSecondUser)
                {
                    lFirst.Add(player.Id);
                }
                var newMatch = new Match
                {
                    Date                       = viewModelAddNewMatch.Date,
                    TypeMatch                  = viewModelAddNewMatch.TypeMatch,
                    FirstPlayerId              = viewModelAddNewMatch.FirstUser.Id,
                    FirstClubId                = viewModelAddNewMatch.FirstClub.Id,
                    FirstPlayerGoal            = viewModelAddNewMatch.FirstUserGoals,
                    ListOfScoredFirstPlayerId  = lFirst,
                    SecondPlayerId             = viewModelAddNewMatch.SecondUser.Id,
                    SecondClubId               = viewModelAddNewMatch.SecondClub.Id,
                    SecondPlayerGoal           = viewModelAddNewMatch.SecondUserGoals,
                    ListOfScoredSecondPlayerId = lSecond
                };
                ListOfMatches.Add(newMatch);
            }
        }
Exemple #2
0
 public AddNewMatchWindow(ViewModelAddNewMatch viewModelAddNewMatch)
 {
     DataContext = viewModelAddNewMatch;
     InitializeComponent();
 }