public ActionResult <int> CreateRoulette()
        {
            Roulette roulette = new Roulette();

            roulette.Status = false;
            var rouleteResponse = rouletteApiContext.Roulettes.Add(roulette);

            rouletteApiContext.SaveChanges();
            return(Ok(rouleteResponse.Entity.RouletteId));
        }
Exemple #2
0
        public ActionResult <Bet> AddBet(int userId, int rouletteId, [FromBody] Bet bet)
        {
            var user = rouletteApiContext.Users.Where(x => x.UserId == userId).FirstOrDefault();

            bet.User = user;
            var roulete = rouletteApiContext.Roulettes.Where(x => x.RouletteId == rouletteId).FirstOrDefault();

            bet.Roulette = roulete;
            bet.Color    = bet.Number % 2 == 0 ? "red":"black";
            var betResponse = rouletteApiContext.Bets.Add(bet);

            rouletteApiContext.SaveChanges();
            return(Ok(betResponse.Entity));
        }