public List<DraftPick> GenerateAllDraftPicks()
        {
            int iOverallNum = 0;

            int iNumTeams = FantasyTeams.Count();
            int iNumRounds = NumQB + NumRB + NumWR + NumTE + NumK + NumFX + NumDEF + NumBN;

            List<DraftPick> allPicks = new List<DraftPick>();
            for (int iRoundIterator = 0; iRoundIterator < iNumRounds; iRoundIterator++)
            {
                if (iRoundIterator % 2 == 0)        // Straight through
                {
                    for (int iTeamIterator = 0; iTeamIterator < iNumTeams; iTeamIterator++)
                    {
                        DraftPick dp = new DraftPick() { FantasyTeam = FantasyTeams[iTeamIterator], OverallPickNum = iOverallNum++ };
                        allPicks.Add(dp);
                        DB4ODataRepository.Instance.SaveDraftPick(dp);
                    }
                }
                else                                // Reverse order
                {
                    for (int iTeamIterator = iNumTeams - 1; iTeamIterator >= 0; iTeamIterator--)
                    {
                        DraftPick dp = new DraftPick() { FantasyTeam = FantasyTeams[iTeamIterator], OverallPickNum = iOverallNum++ };
                        allPicks.Add(dp);
                        DB4ODataRepository.Instance.SaveDraftPick(dp);
                    }
                }
            }

            return allPicks;
        }
        public DraftBoardViewModel(FantasySeason season)
        {
            DraftSelectedPlayerCmd = new DelegateCommand(DraftSelectedPlayer, CanDraftSelectedPlayer);
            SearchModule = new PlayerSearcher(DB4ODataRepository.Instance);

            Season = season;
            OngoingPicks = Season.RetrieveAllDraftPicks(out _currentOverallPick);

            //foreach (var item in OngoingPicks.Where<DraftPick>(dp => dp.NFLPlayer.Position == NFLPosition.K))
            //{
            //    Console.WriteLine(item.FantasyTeam.FantasyCoach.Name + " K " + item.NFLPlayer.FirstName + " " + item.NFLPlayer.LastName);
            //}

            //foreach (var item in OngoingPicks.Where<DraftPick>(dp => dp.FantasyTeam.FantasyCoach.Name == "Anthony"))
            //{
            //    Console.WriteLine("-------------------------------------");
            //    foreach (var item2 in item.FantasyTeam.RosterSpots)
            //    {
            //        Console.WriteLine(item2.Position.ToString() + " " + item2.FilledDraftPick.NFLPlayer.Position + " " +
            //            item2.FilledDraftPick.NFLPlayer.FirstName + " " + item2.FilledDraftPick.NFLPlayer.FirstName);
            //    }
            //}

            //foreach (var item in OngoingPicks.Where<DraftPick>(dp => dp.FantasyTeam.FantasyCoach.Name == "Anthony"))
            //{
            //    Console.WriteLine(item.FantasyTeam.FantasyCoach.Name + " " + item.FantasyTeam.RosterSpots + " " + item.NFLPlayer.Position + " " + item.NFLPlayer.FirstName + " " + item.NFLPlayer.LastName);
            //}

            if (_currentOverallPick >= OngoingPicks.Count())
            {       // Error or the draft is completed
                CurrentPick = null;
                //return;     // TODO: handle this better - display the draft board and disable all controls?
            }
            else
            {
                CurrentPick = OngoingPicks[_currentOverallPick];
            }

            ExecutePickIfDraftBot(CurrentPick.FantasyTeam.DraftBot);

            new DraftBoardView(this).ShowDialog();
        }
 public void SaveDraftedPlayer(DraftPick pick, RosterPosition positionToFill, NFLPlayer SelectedNFLPlayer)
 {
     DataContainer.Store(pick);
     DataContainer.Store(positionToFill);
     DataContainer.Store(SelectedNFLPlayer);
     DataContainer.Commit();
 }
 internal void SaveDraftPick(DraftPick pick)
 {
     DataContainer.Store(pick);
     DataContainer.Commit();
 }
        private void DraftSelectedPlayer(object obj)
        {
            CurrentPick.NFLPlayer = SelectedNFLPlayer;
            SelectedNFLPlayer.DraftedFantasyTeam = CurrentPick.FantasyTeam;

            DraftPick pick = OngoingPicks[_currentOverallPick];
            pick.FantasyTeam = CurrentPick.FantasyTeam;
            pick.NFLPlayer = SelectedNFLPlayer;
            pick.OverallPickNum = _currentOverallPick;

            RosterPosition positionToFill = CurrentPick.FantasyTeam.GetOpenRosterPosition(DraftManagerUtil.NFLPositionToFantasyPosition(SelectedNFLPlayer.Position));
            if (positionToFill == null)
                return;

            DB4ODataRepository.Instance.SaveDraftedPlayer(pick, positionToFill, SelectedNFLPlayer);

            positionToFill.FilledDraftPick = pick;
            SearchModule.ExecuteSearchCmd.Execute(null);    // Force the search to occur again so the player is removed or their fantasy team appears

            _currentOverallPick++;
            if (_currentOverallPick >= OngoingPicks.Count() ||
                OngoingPicks[_currentOverallPick] == null)
            {
                //throw new Exception();      // TODO: handle properly
                return;
            }

            CurrentPick = OngoingPicks[_currentOverallPick];

            ExecutePickIfDraftBot(CurrentPick.FantasyTeam.DraftBot);

            return;
        }