public bool TakeBet(BetRequestModel betModel)
        {
            if (ValidationManager.ValidateBet(betModel, CurrentRound))
            {
                CurrentRound.PlayerBets.TryAdd(betModel.PlayerId, betModel);
            }

            return(true);
        }
        public bool TakePlayerBet(BetRequestModel betModel)
        {
            if (!_tableManager.TryGetTableById(betModel.TableId, out var table))
            {
                return(false);
            }

            return(table.TakeBet(betModel));
        }
        public BaseResponse BetRequest(BetRequestModel betModel)
        {
            var result = new BaseResponse();

            if (!_engine.TakePlayerBet(betModel))
            {
                result.Success = false;
                result.Message = "Wrong Table State";
            }

            result.Success = true;
            result.Message = "Your bet has been accepted";

            return(result);
        }
Esempio n. 4
0
        public IHttpActionResult Post(BetRequestModel requestModel)
        {
            if (ModelState.IsValid)
            {
                PlaceBetCommand placeBetCommand            = Mapper.Map <PlaceBetCommand>(requestModel);
                IEnumerable <ValidationResult> validations = commandDispatcher.Validate(placeBetCommand);

                ModelState.AddModelErrors(validations);

                if (ModelState.IsValid)
                {
                    BetResponseModel responseModel = new BetResponseModel();
                    responseModel.TicketId = commandDispatcher.Dispatch <PlaceBetCommand, string>(placeBetCommand);

                    return(Ok(responseModel));
                }
            }

            return(BadRequest(ModelState));
        }
Esempio n. 5
0
 public bool ValidateBet(BetRequestModel betModel, RouletteRound currentRound)
 {
     return(betModel.TotalBetAmount > 0 && !betModel.Bets.Any(x => x.BetAmount < 0) &&
            currentRound.State == RoundState.None);
 }