示例#1
0
        private void btn_SaveLeague_Click(object sender, RoutedEventArgs e)
        {
            League newLeague = new League();

            newLeague.GameName     = txt_GameName.Text;
            newLeague.LeagueName   = txt_LeagueName.Text;
            newLeague.Reward       = txt_Reward.Text;
            newLeague.LeagueStatus = "Afventende";
            //removes unwanted words from ComboBoxItem. uses space to go to the start of the word needed
            newLeague.LeagueStatus =
                newLeague.LeagueStatus.Substring(newLeague.LeagueStatus.IndexOf(" ", StringComparison.Ordinal) + 1);
            newLeague.Rounds = cb_Rounds.SelectedIndex + 1;
            IEnumerable <RadioButton> rb_collection = addLeagueWindow.Children.OfType <RadioButton>();

            newLeague.LeagueId = BusinessFacade.SaveLeague(newLeague);
            IEnumerable <TextBox> tb_collection = addLeagueWindow.Children.OfType <TextBox>();

            foreach (var item in tb_collection)
            {
                if (item.Name.Contains("Round"))
                {
                    if (item.IsEnabled)
                    {
                        Round newRound = new Round();
                        newRound.RoundName = item.Text;
                        BusinessFacade.SaveRound(newRound, newLeague.LeagueId);
                    }
                }
            }
            this.Owner.Show();
            this.Close();
        }