Пример #1
0
        public ActionResult Result(Criteria criteria)
        {
            var model = new ResultDto();

            var query = _repo.Query <MatchView>(criteria, x => x.ResultHome.HasValue && x.ResultAway.HasValue);

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

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

            model.Criteria = criteria;
            model.Data     = list;

            return(View(model));
        }
Пример #2
0
        // 比分投注单
        // GET: /Casino/MyCoupon

        public ActionResult MyCoupon()
        {
            var model = new MyCouponDto();

            var days = ConfigGlobal_AcnCasino.CasinoValidDays;

            var query = _repo.Query <MatchView>(
                x => x.PlayTime > DateTime.Now && x.PlayTime < DateTime.Now.AddDays(days))
                        .FindAll(x => !x.ResultHome.HasValue && !x.ResultAway.HasValue)
                        .OrderBy(x => x.PlayTime)
                        .Many <MatchView, ChoiceOption, Guid>(t => t.CasinoItem.ID);

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

            var mList = mapper.Map <IEnumerable <MatchDto> >(query.AsEnumerable());

            mapper = new MapperConfiguration(cfg => cfg.CreateMap <MatchDto, CouponDto>()
                                             .ForMember(d => d.MatchGuid, opt => opt.MapFrom(s => s.ID))).CreateMapper();

            var list = mapper.Map <IEnumerable <CouponDto> >(mList).ToList();

            if (list.Count > 0)
            {
                // 查找当前用户的比分投注项
                var coupons = _repo.Query <CouponView>(x => x.UserID == AcnID);

                if (coupons.Count > 0)
                {
                    mapper = CouponDto.ConfigMapper().CreateMapper();

                    foreach (var c in coupons)
                    {
                        var i = list.FindIndex(x => x.MatchGuid.Equals(c.MatchGuid));

                        if (i >= 0)
                        {
                            list[i] = mapper.Map <CouponDto>(c);
                        }
                    }
                }
            }

            model.Coupons            = list;
            model.CasinoValidDays    = days;
            model.IsShowSubmitButton = list.Count > 0 && list.Any(x => !x.BetResultHome.HasValue && !x.BetResultAway.HasValue);

            return(View(model));
        }
Пример #3
0
        public ActionResult Index()
        {
            var model = new IndexDto();
            var days  = ConfigGlobal_AcnCasino.CasinoValidDays;

            var query = _repo.Query <MatchView>(
                x => x.PlayTime > DateTime.Now && x.PlayTime < DateTime.Now.AddDays(days))
                        .FindAll(x => !x.ResultHome.HasValue && !x.ResultAway.HasValue)
                        .OrderBy(x => x.PlayTime)
                        .Many <MatchView, ChoiceOption, Guid>(t => t.CasinoItem.ID);

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

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

            model.Matches         = list;
            model.CasinoValidDays = days;

            model.Gambler = AcnID > 0 ? _repo.Query <Gambler>(x => x.UserID == AcnID).FirstOrDefault() : null;

            return(View(model));
        }
Пример #4
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));
        }