Exemple #1
0
        private void LoadTeams()
        {
#if DEBUG
            Utility.Announce(string.Format("NFlDivision:LoadTeams: Load teams for {0} code {1}", Season, Code));
#endif
            var strFilter = Filters.TeamFilter();

            var ds = Utility.TflWs.GetTeams(Season, Code);
            var dt = ds.Tables["teams"];
            foreach (DataRow dr in dt.Rows)
            {
                var strTeamCode = dr["teamid"].ToString();
#if DEBUG
                Utility.Announce(string.Format("NFLDivision.LoadTeams: Loading {0} Clip= {1}",
                                               dr["teamname"], dr["clip"]));
#endif
                var nIndex = strFilter.IndexOf(strTeamCode);
                if (nIndex <= -1)
                {
                    continue;
                }
                var t = Masters.Tm.GetTeam(Season, strTeamCode);
                t.CurrentClip = Decimal.Parse(dr["clip"].ToString());                      //  clip is not in the XML
                //t.LoadPlayers();  // lazy load this
                TeamList.Add(t);
            }
        }
 public void SetTeamNames(IEnumerable <Team> teams)
 {
     foreach (var team in teams)
     {
         TeamList.Add(new SelectListItem()
         {
             Value = team.Name.ToString(),
             Text  = team.Name
         });
     }
 }
        public async void CreateTeamAsync()
        {
            string TeamName = await Utils.InputDialog.InputBox(NavigationUtil.Navigation);

            Debug.WriteLine(TeamName);
            TeamViewModel tvm = new TeamViewModel(TeamName, this.Creator);
            Team          t   = tvm.Team;

            Database.Database.AddTeamToDB(ref t);
            TeamList.Add(tvm);
        }
        private void TryAddPitcher(
            PitcherDto item)
        {
            var pitcher = MapDtoToPitcher(item);

            if (TeamList.ContainsKey(item.TeamId))
            {
                TeamList[item.TeamId] = pitcher;
            }
            else
            {
                TeamList.Add(item.TeamId, pitcher);
            }
        }
        private void LoadTeamList(string yearIn)
        {
#if DEBUG
            Utility.Announce(string.Format("LoadTeamList: Loading {0} team List", yearIn));
#endif
            var ds    = Utility.TflWs.GetTeams(yearIn, "");
            var teams = ds.Tables["teams"];
            foreach (DataRow dr in teams.Rows)
            {
                TeamKeyList.Add(yearIn + dr["TEAMID"]);
                TeamList.Add(new NflTeam(dr["TEAMID"].ToString(), yearIn));
            }
#if DEBUG
            Utility.Announce(string.Format("LoadTeamList: Loaded {0} teams.", TeamList.Count));
#endif
        }
Exemple #6
0
        private void LoadTeamList(string yearIn)
        {
            Logger = LogManager.GetCurrentClassLogger();

            Logger.Trace($"LoadTeamList: Loading {yearIn} team List");

            var ds    = Utility.TflWs.GetTeams(yearIn, "");
            var teams = ds.Tables["team"];

            foreach (DataRow dr in teams.Rows)
            {
                TeamKeyList.Add(yearIn + dr["TEAMID"]);
                TeamList.Add(new NflTeam(dr["TEAMID"].ToString(), yearIn));
            }

            Logger.Trace($"LoadTeamList: Loaded {TeamList.Count} teams.");
        }
Exemple #7
0
 public void UpdateTeamList(object sender, EventArgs e)
 {
     TeamList.Clear();
     using (var sqlcmd = new SqlCommandExecutor("EXEC pr_GetTeams"))
         using (var sqlReader = sqlcmd.ExecuteReader())
         {
             while (sqlReader.Read())
             {
                 TeamList.Add(new TeamEntry
                 {
                     Inventory   = sqlReader.GetInt16(0).ToString(),
                     Team        = sqlReader.GetInt16(1).ToString(),
                     PeopleCount = sqlReader.GetInt16(2).ToString(),
                     IsComplete  = sqlReader.GetBoolean(3)
                 });
             }
         }
 }
Exemple #8
0
        private void LoadTeams()
        {
            Announce($"NFlDivision:LoadTeams: Load teams for {Season} code {Code}");

            var ds = Utility.TflWs.GetTeams(Season, Code);
            var dt = ds.Tables["team"];

            foreach (DataRow dr in dt.Rows)
            {
                var strTeamCode = dr["teamid"].ToString();

                Announce($"NFLDivision.LoadTeams: Loading {dr[ "teamname" ]} Clip= {dr[ "clip" ]}");

                var t = Masters.Tm.GetTeam(Season, strTeamCode);
                t.CurrentClip = Decimal.Parse(dr["clip"].ToString());                      //  clip is not in the XML
                //t.LoadLineupPlayers();  // lazy load this
                TeamList.Add(t);
            }
            DumpTeams();
        }
Exemple #9
0
        public void GetAllGames(string gameNumber)
        {
            var db    = new BoardSquaresRepository();
            var teams = db.Context.Database.SqlQuery(typeof(TeamScoringByPlayer), String.Format("SELECT a.*, CASE WHEN t.ID IS NULL THEN -1 ELSE t.ID END as TiebreakerSort FROM FP_TeamScoringSummaryByPlayerView a join FP_GameNumbers g on g.GameNumber = a.GameNumber left join FP_UserTeamTieBreakerPlayers t on a.PlayerID = t.PlayerID AND a.UserTeamID = t.UserTeamID WHERE g.Active = 1 AND GETDATE() > g.CloseDate AND a.GameNumber = '{0}' ", gameNumber)).ToListAsync().Result.Select(r => r as TeamScoringByPlayer).GroupBy(r => r.UserTeamID);

            foreach (var team in teams)
            {
                TeamList.Add(new GameSummaryTeam
                {
                    TeamName  = team.First().UserTeamName,
                    TeamTotal = team.Where(r => !r.TieBreakerPlayer).Sum(r => r.TotalPoints),
                    //TieBreakerTotal = team.Where(r => r.TieBreakerPlayer).Sum(r => r.TotalPoints),
                    TeamPlayers       = team.Where(r => !r.TieBreakerPlayer).OrderByDescending(r => r.TotalPoints).ToList(),
                    TieBreakerPlayers = team.Where(r => r.TieBreakerPlayer).OrderBy(r => r.TiebreakerSort).ToList(),
                    TieBreaker1Score  = team.Where(r => r.TieBreakerPlayer).OrderBy(r => r.TiebreakerSort).ToList().First().TotalPoints,
                    TieBreaker2Score  = team.Where(r => r.TieBreakerPlayer).OrderBy(r => r.TiebreakerSort).ToList().Last().TotalPoints,
                });
            }
            TeamList     = TeamList.OrderByDescending(r => r.TeamTotal).ThenByDescending(r => r.TieBreaker1Score).ThenByDescending(r => r.TieBreaker2Score).ToList();
            SelectedGame = gameNumber;
        }
Exemple #10
0
        public void Remove_Team_Test()
        {
            //arrange
            string name = "TestName";
            int    id   = 98;

            //act
            Team testTeam = new Team()
            {
                Name = name, ID = id
            };
            TeamList testTeamList = new TeamList();

            testTeamList.Add(testTeam);
            testTeamList.Remove(id);


            //assert
            Team lookingTeam = testTeamList.FindByID(id);

            Assert.AreEqual(null, lookingTeam, "Incompatibility in Remove Team from list");
        }
Exemple #11
0
        public void Add_Team_Test()
        {
            //arrange
            string name = "TestName";
            int    id   = 98;

            //act
            Team testTeam = new Team()
            {
                Name = name, ID = id
            };
            TeamList testTeamList = new TeamList();

            testTeamList.Add(testTeam);



            //assert
            Team lookingTeam = testTeamList.FindByID(id);

            Assert.AreEqual(name, lookingTeam.Name, "Incompatibility in Add Team to List");
            Assert.AreEqual(id, lookingTeam.ID, "Incompatibility in Add Team to List");
        }
Exemple #12
0
        public void AddPlayers()
        {
            Team t1 = new Team()
            {
                Id = 1, Name = "Котятки", Country = "Россия"
            };
            Team t2 = new Team()
            {
                Id = 2, Name = "Собачки", Country = "Америка"
            };
            Team t3 = new Team()
            {
                Id = 3, Name = "Львята", Country = "Япония"
            };

            TeamList.Add(t1);
            TeamList.Add(t2);
            TeamList.Add(t3);

            Players.Add(new PlayerViewModel(new Player()
            {
                Id       = 1, Surname = "Козлов", Name = "Денис",
                Birthday = DateTime.Parse("15.07.1993"),
                Weight   = 59, Team = t1
            }));

            Players.Add(new PlayerViewModel(new Player()
            {
                Id       = 2, Surname = "Иванов", Name = "Евгений",
                Birthday = DateTime.Parse("04.09.1989"),
                Weight   = 78, Team = t3
            }));

            Players.Add(new PlayerViewModel(new Player()
            {
                Id       = 3, Surname = "Дуров", Name = "Николай",
                Birthday = DateTime.Parse("21.05.1983"),
                Weight   = 87, Team = t2
            }));

            Players.Add(new PlayerViewModel(new Player()
            {
                Id       = 4, Surname = "Суворов", Name = "Александр",
                Birthday = DateTime.Parse("08.11.1991"),
                Weight   = 64, Team = t3
            }));

            Players.Add(new PlayerViewModel(new Player()
            {
                Id       = 5, Surname = "Семенов", Name = "Олег",
                Birthday = DateTime.Parse("19.02.1996"),
                Weight   = 72, Team = t1
            }));

            Players.Add(new PlayerViewModel(new Player()
            {
                Id       = 6, Surname = "Курвыков", Name = "Алексей",
                Birthday = DateTime.Parse("13.12.1988"),
                Weight   = 102, Team = t2
            }));
        }
        private void Button_Click_AddTournament(object sender, RoutedEventArgs e)
        {
            string name = TourName.Text;

            RefereeList refereeList = new RefereeList();
            bool        AreTeamsValid;
            bool        AreRefereesValid;
            bool        IsTypeValid;
            TeamList    teamList = new TeamList();
            GameTypes   type;

            foreach (var item in RefereesToChoose.RefereesListBox.SelectedItems)
            {
                if (item is Referee referee)
                {
                    refereeList.Add(referee);
                }
            }

            foreach (var item in TeamsToChoose.TeamsListBox.SelectedItems)
            {
                if (item is Team team)
                {
                    teamList.Add(team);
                }
            }
            if (GameTypeComboBox.SelectedItem is GameTypes types)
            {
                type        = types;
                IsTypeValid = true;
            }
            else
            {
                ErrorWindow errorWindow = new ErrorWindow();
                errorWindow.ErrorContent.Text = "Choose Game Type";
                errorWindow.Show();
                return;
            }

            if (refereeList.Count > 0)
            {
                AreRefereesValid = true;
            }
            else
            {
                ErrorWindow errorWindow = new ErrorWindow();
                errorWindow.ErrorContent.Text = "Choose at least one Referee";
                errorWindow.Show();
                return;
            }
            if (teamList.Count >= 2)
            {
                AreTeamsValid = true;
            }
            else
            {
                ErrorWindow errorWindow = new ErrorWindow();
                errorWindow.ErrorContent.Text = "Choose at least two Teams";
                errorWindow.Show();
                return;
            }


            if (IsTypeValid && AreTeamsValid && AreRefereesValid)
            {
                Tournaments tournament = new Tournaments()
                {
                    TeamList = teamList, RefereeList = refereeList, GameTypes = type, Name = name, ID = -1
                };
                TournamentViewModel.Tournaments.Add(tournament);

                ErrorWindow errorWindow = new ErrorWindow()
                {
                    Width = 350
                };
                errorWindow.ErrorContent.Text = "Succesfully added Tourament";
                errorWindow.Show();
                ViewTournaments.TourListBox.Items.Refresh();
                NavigationService.Navigate(ViewTournaments);
            }
        }
Exemple #14
0
 public void AddToDepartment(Team first)
 {
     TeamList.Add(first);
 }