Exemplo n.º 1
0
        public void BetResult(int result)
        {
            BetModelClass betModel = new BetModelClass();

            if (this.number != null)
            {
                if (this.number == result)
                {
                    this.result = true;
                    this.winner = this.value * 5;
                    betModel.Update(this);
                }
                else
                {
                    this.result = false;
                    this.winner = 0;
                    betModel.Update(this);
                }
            }
            if (this.color != null)
            {
                if ((this.color == "negro" && result % 2 == 1) || (this.color == "rojo" && result % 2 == 1))
                {
                    this.result = true;
                    this.winner = (double)this.value * 1.8;
                    betModel.Update(this);
                }
                else
                {
                    this.result = false;
                    this.winner = 0;
                    betModel.Update(this);
                }
            }
        }
Exemplo n.º 2
0
        public IActionResult CreateBet(Bet bet)
        {
            if (bet.validate() != "Ok")
            {
                return(BadRequest(bet.validate()));
            }
            BetModelClass betModel = new BetModelClass();
            int           result   = betModel.Create(bet);

            if (result > 0)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Exemplo n.º 3
0
        public IActionResult CloseRoulette(int rouletteId)
        {
            RouletteModelClass rouletteModel = new RouletteModelClass();
            BetModelClass      betModel      = new BetModelClass();
            Roulette           roulette      = rouletteModel.GetRoulette(rouletteId);
            List <Bet>         bets          = betModel.AllRouletteClose((int)roulette.id);

            roulette.Inactive();
            Random random = new Random();
            int    numero = random.Next(0, 36);

            foreach (Bet bet in bets)
            {
                bet.BetResult(numero);
            }

            return(Ok(bets));
        }