public List<RosterPosition> GenerateRosterSpotsFromSeason(FantasySeason season)
        {
            List<RosterPosition> allSpots = new List<RosterPosition>();

            for (int i = 0; i < season.NumQB; i++)
            { allSpots.Add(new RosterPosition(FantasyPosition.QB)); }

            for (int i = 0; i < season.NumRB; i++)
            { allSpots.Add(new RosterPosition(FantasyPosition.RB)); }

            for (int i = 0; i < season.NumWR; i++)
            { allSpots.Add(new RosterPosition(FantasyPosition.WR)); }

            for (int i = 0; i < season.NumTE; i++)
            { allSpots.Add(new RosterPosition(FantasyPosition.TE)); }

            for (int i = 0; i < season.NumK; i++)
            { allSpots.Add(new RosterPosition(FantasyPosition.K)); }

            for (int i = 0; i < season.NumFX; i++)
            { allSpots.Add(new RosterPosition(FantasyPosition.FX)); }

            for (int i = 0; i < season.NumDEF; i++)
            { allSpots.Add(new RosterPosition(FantasyPosition.DEF)); }

            for (int i = 0; i < season.NumBN; i++)
            { allSpots.Add(new RosterPosition(FantasyPosition.BN)); }

            return allSpots;
        }
 public FantasyTeam(string coachName, FantasySeason season)
 {
     DraftBot = null;
     //DraftBot = new BestAvailableBot(this);
     FantasySeason = season;
     FantasyCoach = new FantasyCoach(coachName);
     RosterSpots = GenerateRosterSpotsFromSeason(season);
 }
        public HomeViewModel()
        {
            RunDraftCmd = new DelegateCommand(RunDraft, CanRunDraft);
            ConfigSeasonCmd = new DelegateCommand(ConfigureSeason, CanConfigureSeason);

            AllSeasons = DB4ODataRepository.Instance.GetAllSeasons();

            if (AllSeasons.Count == 1)
                SelectedSeason = AllSeasons.First<FantasySeason>();
        }
        public DraftConfigureViewModel(FantasySeason fantasySeason)
        {
            AddTeamCmd = new DelegateCommand(AddTeam, CanAddTeam);
            SaveSeasonCmd = new DelegateCommand(SaveSeason);

            this.Season = fantasySeason;

            PossibleNFLSeasons = new List<int>();
            for (int i = 2015; i <= DateTime.Now.Year; i++)
            {
                PossibleNFLSeasons.Add(i);
            }

            new DraftConfigureView(this).ShowDialog();
        }
        private void btnCreateSeason_Click(object sender, RoutedEventArgs e)
        {
            // TODO: Create a new season and open the config view

            FantasySeason x = new FantasySeason("New Season");
            x.NumQB = 1;
            x.NumRB = 1;
            x.NumWR = 1;
            x.NumTE = 1;
            x.NumK = 1;
            x.NumBN = 1;
            x.NumDEF = 1;
            x.NumFX = 0;

            DraftConfigureViewModel configViewModel = new DraftConfigureViewModel(x);
        }
        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();
        }
        internal FantasySeason LoadSeason()
        {
            // TODO: Get the data here

            FantasySeason seasonToReturn = new FantasySeason();
            seasonToReturn.Year = 2015;
            seasonToReturn.NumQB = 1;
            seasonToReturn.NumRB = 2;
            seasonToReturn.NumWR = 2;
            seasonToReturn.NumK = 1;
            seasonToReturn.NumFX = 1;
            seasonToReturn.NumDEF = 1;
            seasonToReturn.NumBN = 5;

            // TODO: get all teams here
            FantasyTeam teamJoe = new FantasyTeam("Joe", seasonToReturn, 1);
            FantasyTeam teamHank = new FantasyTeam("Hank", seasonToReturn, 2);

            seasonToReturn.FantasyTeams.Add(teamJoe);
            seasonToReturn.FantasyTeams.Add(teamHank);

            return seasonToReturn;
        }
 public FantasyTeam(string coachName, FantasySeason season, int draftOrder)
     : this(coachName, season)
 {
     DraftOrder = draftOrder;
 }
 public void UpdateSeason(FantasySeason season)
 {
     DataContainer.Store(season);
     DataContainer.Commit();
 }
 private List<DraftPick> GetAllPicksForSeason(FantasySeason fantasySeason)
 {
     return DataContainer.Query<DraftPick>()
                         .Where<DraftPick>(dp => dp.FantasyTeam.FantasySeason == fantasySeason)
                         .ToList<DraftPick>();
 }
        internal List<DraftPick> GetExistingPicksForSeason(FantasySeason fantasySeason, out int iNumPicks)
        {
            iNumPicks = 0;

            List<DraftPick> allPicks = DB4ODataRepository.Instance.GetAllPicksForSeason(fantasySeason);
            iNumPicks = allPicks.Count<DraftPick>(dp => dp.FantasyTeam != null &&
                                                        dp.FantasyTeam.FantasySeason == fantasySeason &&
                                                        dp.NFLPlayer != null);
                        
            return allPicks;
        }
        internal bool SeasonHasPicks(FantasySeason season)
        {
            var x = DataContainer.Query<DraftPick>()
                                 .Where<DraftPick>(dp => dp.FantasyTeam != null)
                                 .FirstOrDefault<DraftPick>();

            return x != null;
        }
        public void CreateFakeFantasySeasons()
        {
            DeleteAllItemsByType(typeof(FantasySeason));
            DeleteAllItemsByType(typeof(FantasyTeam));

            FantasySeason season = new FantasySeason("Fake Season 1");
            season.Year = 2015;
            season.NumQB = 1;
            season.NumRB = 2;
            season.NumWR = 2;
            season.NumTE = 2;
            season.NumK = 1;
            season.NumFX = 1;
            season.NumDEF = 1;
            season.NumBN = 5;

            FantasyTeam t1 = new FantasyTeam("Anthony", season, 1);
            FantasyTeam t2 = new FantasyTeam("Bob", season, 2);
            FantasyTeam t3 = new FantasyTeam("Charlie", season, 3);

            season.FantasyTeams.Add(t1);
            season.FantasyTeams.Add(t2);
            season.FantasyTeams.Add(t3);

            DataContainer.Store(t1.DraftBot);
            DataContainer.Store(t2.DraftBot);
            DataContainer.Store(t3.DraftBot);

            // Editmark: I belive the draft bot ranked players aren't being saved to the DB after population. Address here?

            DataContainer.Store(t1);
            DataContainer.Store(t2);
            DataContainer.Store(t3);
            DataContainer.Store(season);

            DataContainer.Commit();
        }