示例#1
0
        // 投输赢
        // GET: /Casino/SingleChoice/id

        public ActionResult SingleChoice(Guid id)
        {
            var model = new SingleChoiceDto();

            var gambler = _repo.Query <Gambler>(x => x.UserID == AcnID).FirstOrDefault();

            model.MyCash = gambler?.Cash ?? 0f;

            // 判断玩家是否有单注限制
            var leagueGuid = _repo.Single <Match>(id)?.LeagueGuid;

            if (leagueGuid.HasValue)
            {
                model.BetLimit = GamblerDW.GetGamblerBetLimit(AcnID, leagueGuid.Value);
            }
            else
            {
                model.BetLimit = model.MyCash;
            }

            model.Match     = MatchDto.Single(id);
            model.MatchGuid = id;

            return(View(model));
        }
示例#2
0
        // 猜比分
        // GET: /Casino/MatchResult/id

        public ActionResult MatchResult(Guid id)
        {
            var model = new MatchResultDto
            {
                Match     = MatchDto.Single(id),
                MatchGuid = id
            };

            return(View(model));
        }
示例#3
0
        public ActionResult Detail(Guid id)
        {
            var model = new DetailDto {
                Match = MatchDto.Single(id)
            };

            var query = _repo.Query <BetView>(x => x.CasinoItem.MatchGuid == id)
                        .Many <BetView, BetDetail, int>(t => t.ID);

            var mapper = BetDto.ConfigMapper().CreateMapper();

            var list = mapper.Map <IEnumerable <BetDto> >(query.AsEnumerable());

            model.Bets = list;

            return(View(model));
        }
示例#4
0
        public ActionResult MatchResult(MatchResultDto model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var id = model.MatchGuid;

                    var bet = new Bet
                    {
                        UserID   = AcnID,
                        UserName = User.Identity.Name
                    };

                    bet.Place(id, model.ResultHome, model.ResultAway);

                    //投注成功

                    TempData["DataUrl"] = $"data-url=/Casino/GameBet/{id}";
                    return(RedirectToAction("GameBet", new { id }));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Warn", ex.Message);
                }
            }
            else
            {
                ModelState.AddModelError("Warn", "请正确填写比赛结果比分");
            }

            model.Match = MatchDto.Single(model.MatchGuid);
            //model.MatchGuid = model.MatchGuid;

            return(View(model));
        }
示例#5
0
        // 我要投注
        // GET: /Casino/GameBet

        public ActionResult GameBet(Guid id)
        {
            var model = new GameBetDto();

            var gambler = _repo.Query <Gambler>(x => x.UserID == AcnID).FirstOrDefault();

            model.MyCash = gambler?.Cash ?? 0f;

            model.Match = MatchDto.Single(id);

            // model.MyBets
            var betsQuery = _repo.Query <BetView>(x =>
                                                  x.UserID == AcnID && x.CasinoItem.MatchGuid == id)
                            .Many <BetView, BetDetail, int>(t => t.ID);

            var mapper = BetDto.ConfigMapper().CreateMapper();

            var bList = mapper.Map <IEnumerable <BetDto> >(betsQuery.AsEnumerable());

            model.MyBets = bList;

            // model.HistoryMatches
            var match = _repo.Single <Match>(id);

            var matchesQuery = _repo.Query <MatchView>(x => x.ResultHome.HasValue && x.ResultAway.HasValue)
                               .FindAll(x => x.Home.ID.Equals(match.Home) && x.Away.ID.Equals(match.Away) ||
                                        x.Home.ID.Equals(match.Away) && x.Away.ID.Equals(match.Home));

            mapper = MatchDto.ConfigMapper().CreateMapper();

            var mlist = mapper.Map <IEnumerable <MatchDto> >(matchesQuery.AsEnumerable());

            model.HistoryMatches = mlist;

            return(View(model));
        }
示例#6
0
        public ActionResult SingleChoice(SingleChoiceDto model)
        {
            var id         = model.MatchGuid;
            var leagueGuid = _repo.Single <Match>(id)?.LeagueGuid;

            if (ModelState.IsValid)
            {
                try
                {
                    //Gambler in Lower could not bet above the SingleBetLimit of DefaultLeague (Contest)
                    if (leagueGuid != null && leagueGuid.Equals(ConfigGlobal_AcnCasino.DefaultLeagueID))
                    {
                        var g = GamblerDW.Single(AcnID, leagueGuid.Value);

                        // 如果没有投过注,或投注量小于标准,判断是否在下半赛区
                        if (g == null || g.TotalBet < ConfigGlobal_AcnCasino.TotalBetStandard)
                        {
                            var    singleBetLimit  = ConfigGlobal_AcnCasino.SingleBetLimit;
                            double?alreadyMatchBet = null;

                            // 获取单场比赛当前用户投注总额
                            var item = _repo.Query <CasinoItem>(x => x.MatchGuid == id &&
                                                                x.ItemType == CasinoType.SingleChoice).FirstOrDefault();
                            var myBets = _repo.Query <Bet>(x => x.CasinoItemGuid == item.ID && x.UserID == AcnID);

                            if (myBets.Count > 0)
                            {
                                alreadyMatchBet = myBets.Sum(x => x.BetAmount);
                            }

                            // 已投注量+本次投注量不可超过单场比赛限额
                            if (singleBetLimit > 0 && (alreadyMatchBet ?? 0) + model.BetAmount > singleBetLimit)
                            {
                                throw new Exception($"下半赛区每个玩家单场投注总量不能超过{singleBetLimit.ToString("N0")}博彩币");
                            }
                        }
                    }

                    //if (model.BetAmount > ConfigGlobal_AcnCasino.SingleBetLimit)
                    //{ throw new Exception($"移动版单场不能超过{ConfigGlobal_AcnCasino.SingleBetLimit.ToString("f0")}博彩币"); }

                    var bet = new Bet
                    {
                        UserID    = AcnID,
                        UserName  = User.Identity.Name,
                        BetAmount = model.BetAmount
                    };

                    bet.Place(id, model.SelectedOption);

                    //投注成功

                    TempData["DataUrl"] = $"data-url=/Casino/GameBet/{id}";
                    return(RedirectToAction("GameBet", new { id }));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("Warn", ex.Message);
                }
            }
            else
            {
                ModelState.AddModelError("Warn", "请正确填写投注单");
            }

            var gambler = _repo.Query <Gambler>(x => x.UserID == AcnID).FirstOrDefault();

            model.MyCash = gambler?.Cash ?? 0f;

            if (leagueGuid.HasValue)
            {
                model.BetLimit = GamblerDW.GetGamblerBetLimit(AcnID, leagueGuid.Value);
            }
            else
            {
                model.BetLimit = model.MyCash;
            }

            model.Match = MatchDto.Single(model.MatchGuid);

            return(View(model));
        }