Пример #1
0
        public void SaveCurrentWeeksPicks(NFLWeekDTO currentWeek, string userId)
        {
            var gamePicksList = new List <NFLGamePick>();

            currentWeek.NFLGames.ToList().ForEach(g => { if (g.HomeTeamPicked || g.VisitingTeamPicked)
                                                         {
                                                             gamePicksList.Add(CreateGamePick(g, userId));
                                                         }
                                                  });
            NFLSeasonService.SaveNFLPicks(gamePicksList);
        }
Пример #2
0
        public NFLWeekDTO GetCurrentWeekPicks(string userId)
        {
            var currentCentralTime = TimeHelpers.GetCurrentCentralTime();
            var currentWeek        = GetCurrentWeek();
            var currentPicks       = NFLSeasonService.GetNFLPicks(currentWeek.NFLWeekId, userId);

            var mappedWeek = Mapper.Map <NFLWeekDTO>(currentWeek);

            mappedWeek.NFLGames.ToList().ForEach(g => g.PicksAllowed = g.GameTime > currentCentralTime);

            foreach (var pick in currentPicks)
            {
                var game = mappedWeek.NFLGames.First(g => g.NFLGameId == pick.NFLGameId);

                game.HomeTeamPicked     = game.HomeTeam.NFLTeamId == pick.NFLTeamId;
                game.VisitingTeamPicked = game.VisitingTeam.NFLTeamId == pick.NFLTeamId;
            }

            return(mappedWeek);
        }
Пример #3
0
        public void SaveWeekScores(NFLWeekDTO week)
        {
            var currentWeek = NFLSeasonService.GetNFLWeek(week.NFLWeekId);

            foreach (var game in week.NFLGames)
            {
                var nflGame = currentWeek.NFLGames.First(g => g.NFLGameId == game.NFLGameId);
                nflGame.HomeTeamScore     = game.HomeTeamScore;
                nflGame.VisitingTeamScore = game.VisitingTeamScore;

                if (nflGame.HomeTeamScore > nflGame.VisitingTeamScore)
                {
                    nflGame.WinningTeamId = nflGame.HomeTeamId;
                }

                if (nflGame.HomeTeamScore < nflGame.VisitingTeamScore)
                {
                    nflGame.WinningTeamId = nflGame.VisitingTeamId;
                }
            }

            NFLSeasonService.SaveChanges();
        }