public override void RenderAsHtml()
        {
            LeagueInFocus = LeagueToFocusOn();
            if (TimeKeeper.CurrentWeek(DateTime.Now) > 16)
            {
                LeagueInFocus = Constants.K_LEAGUE_Gridstats_NFL1;
            }

            var totalPlayers = 0;
            var season       = new NflSeason(
                Season,
                teamsOnly: true);

            foreach (var team in season.TeamList)
            {
                TeamCode = team.TeamCode;
                Execute();
                totalPlayers += PlayerCount;
#if DEBUG2
                break;
#endif
            }
            DumpErrors();
            TraceIt($"   {TeamCode} Player Count : {totalPlayers}");
        }
        private bool IsYahooSeason()
        {
            var currentWeek = TimeKeeper.CurrentWeek(
                TimeKeeper.CurrentDateTime());

            if (currentWeek > 0 && currentWeek < 17)
            {
                return(true);
            }
            return(false);
        }
 public void TestCurrentWeek()
 {
     var sut = new TimeKeeper( new FakeClock( new DateTime( 2015, 03, 16 ) ) );  // set clock to March
      Assert.AreEqual( sut.CurrentWeek(), 0 );
 }
 public void TestTimekeeperKnowslastweek()
 {
     var sut = new TimeKeeper(new FakeClock(new DateTime(2015, 11, 17, 12, 0, 0)));
     Console.WriteLine( "This week is {0}:{1}", sut.CurrentSeason(), sut.CurrentWeek());
     Console.WriteLine("Last week is {0}:{1}", sut.CurrentSeason(), sut.PreviousWeek());
     Assert.IsTrue(sut.PreviousWeek().Equals("10"));
 }
Exemple #5
0
        private void LoadDataTable()
        {
#if DEBUG2
            var tCount = 0;
#endif
            var asOfWeek = int.Parse(Week);
            foreach (KeyValuePair <string, NflTeam> teamPair in TeamList)
            {
                var team = teamPair.Value;

                FptsAllowed fptsAllowed = new FptsAllowed(
                    team.TeamCode);
                FptsAllowed totalFptsAllowed = new FptsAllowed(
                    team.TeamCode);
                for (var w = TimeKeeper.CurrentWeek(
                         DateTime.Now) - 1; w > 0; w--)
                {
                    if (w > asOfWeek)
                    {
                        continue;
                    }
                    if (w < asOfWeek - 5)
                    {
                        continue;
                    }

                    string theWeek = $"{w:0#}";

                    var ds = Utility.TflWs.GameForTeam(
                        Season,
                        theWeek,
                        team.TeamCode);
                    if (ds.Tables[0].Rows.Count != 1)
                    {
                        continue;
                    }

                    fptsAllowed = CalculateFptsAllowed(
                        team,
                        theWeek,
                        ds);

                    totalFptsAllowed.Add(
                        fptsAllowed);
                    AccumulateFptsAllowed(
                        fptsAllowed);
                }

                DumpBreakdowns(
                    team.TeamCode);

#if DEBUG2
                tCount++;
                if (tCount > 0)
                {
                    break;
                }
#endif
            }

            RankTotalPoints();
            RankPointsToQbs();
            RankPointsToRbs();
            RankPointsToWrs();
            RankPointsToTes();
            RankPointsToPks();

            //  Build the output table
            foreach (FptsAllowed item in TotalFpAllowedList)
            {
                DataRow teamRow = Data.NewRow();
                teamRow["TEAM"] = item.TeamCode;
                teamRow["OPP"]  = Opponent(
                    item.TeamCode);
                teamRow["TOTAL"] = 0;
                teamRow["QB"]    = LinkFor(item.TeamCode, "QB", item.ToQbs, item.ToQbsRank);
                teamRow["RB"]    = LinkFor(item.TeamCode, "RB", item.ToRbs, item.ToRbsRank);
                teamRow["WR"]    = LinkFor(item.TeamCode, "WR", item.ToWrs, item.ToWrsRank);
                teamRow["TE"]    = LinkFor(item.TeamCode, "TE", item.ToTes, item.ToTesRank);
                teamRow["PK"]    = LinkFor(item.TeamCode, "PK", item.ToPks, item.ToPksRank);

                teamRow["TOTAL"] = item.TotPtsAllowed();
                Data.Rows.Add(teamRow);
            }
        }