Beispiel #1
0
        public IActionResult PlaceBet(int betAmount, string betType)
        {
            string userId = _userManager.GetUserId(User);

            List <Zebra> list = context.Zebras //which zebra has right ssn? pull current data from persistant
                                               //.Include(z => z.SSN)
                                .Where(z => z.SSN == userId)
                                .ToList();

            user = list[0];

            if (betAmount <= user.Bank)
            {
                context.Zebras.Find(user.Id).Bank -= betAmount;
                context.SaveChanges();
                //user.Bank -= betAmount;
                Bet bet = new Bet
                {
                    Amount = betAmount,
                    Type   = betType
                };
                bets.Add(bet);
            }
            return(Redirect("/Roulette"));
        }
 public IActionResult Add(AddUserViewModel addUserViewModel)
 {
     context.Zebras.Add(new Zebra
     {
         SSN       = addUserViewModel.SSN,
         Username  = addUserViewModel.Name,
         Bank      = 5000,
         UserLevel = 1
     });
     context.SaveChanges();
     return(Redirect("/Roulette"));
 }
Beispiel #3
0
 public static NoContentResult UpdateRouletteStateIfExists(RouletteDbContext context, Roulette rouletteToBeUpdated)
 {
     if (rouletteToBeUpdated != null)
     {
         rouletteToBeUpdated.IsOpen = true;
         context.Roulettes.Update(rouletteToBeUpdated);
         context.SaveChanges();
         return(new NoContentResult());
     }
     return(null);
 }
Beispiel #4
0
        public IQueryable <T> Find()
        {
            var result = _set.AsQueryable();

            _context.SaveChanges();
            return(result);
        }
Beispiel #5
0
 public void SaveChanges()
 {
     _context.SaveChanges();
 }