Esempio n. 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);
        }
Esempio n. 2
0
        public void Post(NFLWeekDTO value)
        {
            try
            {
                _scoresAdapter.SaveWeekScores(value);
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content      = new StringContent(ex.Message),
                    ReasonPhrase = "Invalid Request"
                };

                throw new HttpResponseException(resp);
            }
        }
Esempio n. 3
0
        public void Post(NFLWeekDTO value)
        {
            try
            {
                var userId = SecurityHelpers.GetUserId();
                _gamePicksAdapter.SaveCurrentWeeksPicks(value, userId);
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content      = new StringContent(ex.Message),
                    ReasonPhrase = "Invalid Request"
                };

                throw new HttpResponseException(resp);
            }
        }
Esempio n. 4
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();
        }