Example #1
0
 /// <summary>
 /// Открыть окно с деталями матча
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OpenMatchDetails()
 {
     if (matchesDataGrid.SelectedItems.Count > 0)
     {
         for (int i = 0; i < matchesDataGrid.SelectedItems.Count; i++)
         {
             if (matchesDataGrid.SelectedItems[i] is Match match)
             {
                 MatchDataForm matchDataForm = new MatchDataForm(match.Id, match.TitleLong);
                 matchDataForm.Show();
             }
         }
     }
 }
        /// <summary>
        /// Создает новый матч
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateNewMatchButton_Click(object sender, RoutedEventArgs e)
        {
            Match match = new Match
            {
                Team1 = db.Teams.Where(t => t.Name == team1List.SelectedValue.ToString()).SingleOrDefault(),
                Team2 = db.Teams.Where(t => t.Name == team2List.SelectedValue.ToString()).SingleOrDefault()
            };

            db.Matches.Local.Add(match);

            db.SaveChanges();

            MatchDataForm matchDataForm = new MatchDataForm(match.Id, match.TitleLong);

            matchDataForm.Show();

            Close();
        }