Ejemplo n.º 1
0
        public ActionResult SaveResultBets(string groupGamesResult, string playoffGamesResult, string topScorerResult, int sportsEventId = 1)
        {
            _cacheService.ClearAll();
            var groupGamesResultViewModel   = _javaScriptSerializer.Deserialize <List <GameResultViewModel> >(groupGamesResult);
            var playoffGamesResultViewModel = _javaScriptSerializer.Deserialize <List <PlayoffBetViewModel> >(playoffGamesResult);
            var topScorerBet = topScorerResult != null?_javaScriptSerializer.Deserialize <PlayerViewModel>(topScorerResult) : null;

            var userId = GetUserId();

            var userBet = _betController.CreateUserBet(groupGamesResultViewModel, playoffGamesResultViewModel, topScorerBet, sportsEventId, userId, true);

            var userBetId = _userBetRepository.SaveOrUpdateUserBet(userBet);

            var result = new Results
            {
                UserBetId     = userBetId,
                SportsEventId = sportsEventId
            };

            _resultRepository.SaveOrUpdateResult(result);

            var invalidUserScores = _userScoreService.UpdateUserScores(userBet);

            _cacheService.ClearAll();

            return(Content(invalidUserScores));
        }
Ejemplo n.º 2
0
        private bool CreateAndInsertUserBet(int sportsEventId,
                                            IEnumerable <GameResultViewModel> groupGamesResultViewModel,
                                            PlayerViewModel topScorerBet,
                                            List <PlayoffBetViewModel> playoffGamesResultViewModel)
        {
            var userId  = GetUserId();
            var userBet = CreateUserBet(groupGamesResultViewModel, playoffGamesResultViewModel, topScorerBet, sportsEventId, userId);

            if (PlayoffBetsNotValid(userBet))
            {
                return(false);
            }

            _userBetRepository.SaveOrUpdateUserBet(userBet);

            return(true);
        }