Exemplo n.º 1
0
        public ActionResult doBet(Bet toAdd)
        {
            try
            {
                ApplicationUser currentUser = CurrentUser();
                if (currentUser.userStatus == "baned")
                {
                    TempData["badState"] = "Вы не можете делать ставки, вы забанены";
                    return RedirectToAction("Index", "Home");
                }
                SportEvent current = db.events.Single(a => a.Id == toAdd.betEventId);
                if (current.state != eventState.preview && current.state != eventState.live)
                {
                    TempData["badState"] = "Невозможно сделать ставку на это событие";
                    return RedirectToAction("Index", "Home");
                }

                if (toAdd.amount > currentUser.userAmount)
                {
                    TempData["badState"] = "Недостаточно денег на балансе, пополните баланс";
                    return RedirectToAction("Index", "Home");
                }
                toAdd.userId = currentUser.Id;
                toAdd.state = "waiting";
                currentUser.userAmount -= toAdd.amount;
                db.bets.Add(toAdd);
                db.SaveChanges();
                TempData["goodState"] = "Ставка сделана!";
                return RedirectToAction("Index", "Home");
            }
            catch (ArgumentNullException e)
            {
                return HttpNotFound();
            }
        }
Exemplo n.º 2
0
        private float myBetCoefficient(Bet myBet, SportEvent sevent)
        {
            switch(myBet.betType)
            {
                case "П1":
                    return sevent.firstWin;
                case "П2":
                    return sevent.secondWin;
                case "Н":
                    return sevent.gameTie;
                case "НН":
                    return sevent.overallTie;
                case "Н1":
                    return sevent.tieByFirst;
                case "Н2":
                    return sevent.tieBySecond;
                case "Тотал":
                    return sevent.total;
                case "Б":
                    return sevent.b;
                case "М":
                    return sevent.m;
            }

            return 0.0f;
        }