public async Task <ActionResult> ChangePassword(ChangePasswordViewModel model)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            aJaxDto ajd = new aJaxDto();

            ajd.isTrue = false;
            if (!ModelState.IsValid)
            {
                return(Json(ajd, JsonRequestBehavior.AllowGet));
            }
            var result = await UserManager.ChangePasswordAsync(model.userId, model.OldPassword, model.NewPassword);

            if (result.Succeeded)
            {
                var user = await UserManager.FindByIdAsync(model.userId);

                if (user != null)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);
                }
                ajd.isTrue = true;
                return(Json(ajd, JsonRequestBehavior.AllowGet));
            }
            //AddErrors(result);
            return(Json(ajd, JsonRequestBehavior.AllowGet));
        }
        public ActionResult _MoneyChange(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (User.Identity.GetUserId() == null)
                {
                    //ajd.ErrorMsg = "下注前須先登入\n請先至會員登入中心進行登入註冊,謝謝";
                    ajd.isTrue = false;
                    throw new Exception("error");
                }
                ProductApiModel pm = new ProductApiModel();

                Product product = new MallRepository().Get(id);
                // List<Product> productAll = new MallRepository().getAll();
                cfgUnit unit = new UnitsRepository().getValid(product.unitSn);

                pm.unit    = unit;
                pm.product = product;
                //pm.producList = productAll.Where(x => x.id < 5).ToList();
                var gold = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()).Where(x => x.unitSn == product.unitSn).FirstOrDefault();
                ViewBag.gold   = (gold != null) ? gold.Asset : 0;
                ViewBag.change = (product.Price > ViewBag.gold) ? 0 : 1;
                return(View(pm));
            }
            catch
            {
                //ajd.isTrue = false;
                return(Json(ajd));
            }
        }
        public ActionResult _FishPay(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (User.Identity.GetUserId() == null)
                {
                    //ajd.ErrorMsg = "下注前須先登入\n請先至會員登入中心進行登入註冊,謝謝";
                    ajd.isTrue = false;
                    throw new Exception("error");
                }

                Product         product    = new MallRepository().Get(id);
                List <Product>  productAll = new MallRepository().getAll();
                cfgUnit         unit       = new UnitsRepository().getValid(product.unitSn);
                ProductApiModel pm         = new ProductApiModel();
                pm.unit       = unit;
                pm.product    = product;
                pm.producList = productAll.Where(x => x.unitSn == 3 && x.type == 3).ToList();
                return(View(pm));
            }
            catch
            {
                return(Json(ajd));
            }
        }
Exemplo n.º 4
0
        public async System.Threading.Tasks.Task <aJaxDto> reopenTopic(StopTopicReq str)
        {
            aJaxDto             ajd      = new aJaxDto();
            HttpResponseMessage response = await client.PostAsJsonAsync("api/reopenTopic", str);

            if (response.IsSuccessStatusCode)
            {
                ajd.isTrue = true;
            }
            else
            {
                ajd.isTrue    = false;
                ajd.ErrorCode = 500;
                ajd.ErrorMsg  = response.ReasonPhrase;
            }
            await reflashGameListAsync();

            return(ajd);
        }
Exemplo n.º 5
0
        public async System.Threading.Tasks.Task <aJaxDto> setWinnerPay(SetWinnerReq swq)
        {
            aJaxDto             ajd      = new aJaxDto();
            HttpResponseMessage response = await client.PostAsJsonAsync("api/setLiveWinnerPay", swq);

            if (response.IsSuccessStatusCode)
            {
                List <payoutDto> payoutList = await response.Content.ReadAsAsync <List <payoutDto> >();

                new AssetsRepository().AddLiveAssetsByPay(payoutList);
                ajd.isTrue = true;
                await reflashGameListAsync();
            }
            else
            {
                ajd.isTrue    = false;
                ajd.ErrorCode = 500;
                ajd.ErrorMsg  = response.ReasonPhrase;
            }
            // await reflashGameListAsync();
            return(ajd);
        }
        public async System.Threading.Tasks.Task <string> pays(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                gameDto         game   = null;
                GamesRepository _games = new GamesRepository();
                game = await _games.GetGameDetail(id);

                if (1 == 1)
                {
                    List <payoutDto> payoutList = new List <payoutDto>();
                    StartBetReq      sbr        = new StartBetReq();
                    sbr.UserID = new AccountRepository().getUserEmail("*****@*****.**").Id;
                    sbr.comSn  = 1;
                    sbr.gameSn = id;
                    ajd        = await _games.pays(sbr, game.betModel);

                    game = await _games.GetGameDetail(sbr.gameSn);

                    rebearpage(id);



                    new SignalRHelper().UpdateTopic(game, encryptedKey, game.md5GameSn);
                }
            }
            catch
            {
                ajd.isTrue    = false;
                ajd.ErrorCode = 500;
            }

            return(JsonConvert.SerializeObject(ajd));
        }
Exemplo n.º 7
0
        public async System.Threading.Tasks.Task <aJaxDto> paysRollback(StartBetReq sbr)
        {
            aJaxDto             ajd      = new aJaxDto();
            HttpResponseMessage response = await client.PostAsJsonAsync("api/paysRollback", sbr);

            if (response.IsSuccessStatusCode)
            {
                List <payoutDto> payoutList = await response.Content.ReadAsAsync <List <payoutDto> >();

                new AssetsRepository().AddAssetsByPayRollback(payoutList);

                ajd.isTrue = true;
                await reflashGameListAsync();
            }
            else
            {
                ajd.isTrue    = false;
                ajd.ErrorCode = 500;
                ajd.ErrorMsg  = response.ReasonPhrase;
            }
            await reflashGameListAsync();

            return(ajd);
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Recommend(string recommend)
        {
            var     r   = new UserRepository().getRecommend();
            aJaxDto ajd = new aJaxDto();

            foreach (var re in r)
            {
                var v = new UserRepository().getRecommendStart((int)re.ReId);
                if (v.edate > DateTime.Now)
                {
                    if (recommend == re.code)
                    {
                        ajd.isTrue = true;
                    }
                    else
                    {
                        ajd.isTrue   = false;
                        ajd.ErrorMsg = "推薦碼錯誤";
                    }
                }
            }

            return(Json(ajd, JsonRequestBehavior.AllowGet));
        }
        public async System.Threading.Tasks.Task <JsonResult> SetWinnerPay(GamePostViewModel gp, int topicSn)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            aJaxDto ajd = new aJaxDto();

            try
            {
                gameDto         gd     = null;
                GamesRepository _games = new GamesRepository();

                gameDto game = null;
                gd = await _games.GetGameDetail(gp.game.sn);

                gp.gamepost.edate   = gd.edate;
                gp.gamepost.sdate   = DateTime.Now;
                gp.gamepost.inpdate = DateTime.Now;
                gp.game.sdate       = DateTime.Now;
                gp.game.edate       = gd.gamedate;
                gp.game.gamedate    = gd.gamedate;

                for (int i = 0; i < gd.topicList.Count; i++)
                {
                    gp.game.topicList[i].sdate = gd.topicList[i].sdate;
                    gp.game.topicList[i].edate = gd.topicList[i].edate;
                }



                List <choiceDto> choice = new List <choiceDto>();
                foreach (topicDto t in gp.game.topicList)
                {
                    choice.AddRange(t.choiceList);
                }

                /*bool haveTrue = false;
                 * bool allReturn = true;
                 * foreach (choiceDto cho in choice)
                 * {
                 *  if (cho.isTrue.HasValue && cho.isTrue == 1)
                 *      haveTrue = true;
                 *  if (cho.isTrue != 2)
                 *      allReturn = false;
                 *
                 * }*/

                SetWinnerReq swq = new SetWinnerReq();
                swq.UserID     = gp.game.userId;
                swq.comSn      = 1;
                swq.choiceList = choice;
                swq.gameSn     = gp.game.sn;
                swq.topicSn    = topicSn;
                //ajd = await _games.pays(sbr, game.betModel);
                ajd = await _games.setWinnerPay(swq);

                new SignalRHelper().UpdateTopic(gp.game, encryptedKey, gp.game.md5GameSn);

                // Return the URI of the created resource.
            }
            catch
            {
                ajd.isTrue    = false;
                ajd.ErrorCode = 500;
            }

            return(Json(ajd, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
        public async System.Threading.Tasks.Task <ActionResult> Create(betViewModel bv)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (User.Identity.GetUserId() == null)
                {
                    ajd.ErrorMsg  = "預測前須先登入\n請先至會員登入中心進行登入註冊,謝謝";
                    ajd.isTrue    = false;
                    ajd.ErrorCode = 2;
                    throw new Exception("error");
                }

                if (!ModelState.IsValid)
                {
                    ajd.ErrorMsg = "";
                    foreach (var errs in ModelState.Values.Where(p => p.Errors.Count > 0).Select(p => p.Errors).Distinct())
                    {
                        foreach (var e in errs)
                        {
                            ajd.ErrorMsg += e.ErrorMessage + "\n";
                        }
                        //ajd.ErrorMsg += "";
                    }

                    ajd.isTrue = false;
                    throw new Exception("error");
                }
                if (!User.Identity.GetEmailConfirmed() && !User.Identity.GetPhoneNumberConfirmed())
                {
                    ajd.ErrorMsg = "預測前須先完成Email驗證以及手機驗證\n請先至會員中心進行Email驗證和手機驗證,謝謝";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }

                if (!User.Identity.GetEmailConfirmed())
                {
                    ajd.ErrorMsg = "預測前須先完成Email驗證\n請先至會員中心進行Email驗證,謝謝";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                if (!User.Identity.GetPhoneNumberConfirmed())
                {
                    ajd.ErrorMsg = "預測前須先完成手機驗證\n請先至會員中心進行手機驗證,謝謝";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }


                List <betDto>   bet_list      = new List <betDto>();
                GamesRepository _game         = new GamesRepository();
                int             firstChoiceSn = bv.betList.First().getChoiceSn(System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"]);
                gameDto         gd            = await _game.GetGameDetailByChoiceSn(firstChoiceSn);

                double Assets = new AssetsRepository().getAssetsByUserID(User.Identity.GetUserId(), 1);
                Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
                //竄改
                int[] bvarray = new int[] { 2, 2, 2, 4, 5 };
                if (gd.betModel == 6)
                {
                    int    bj         = 0;
                    double moneyclcik = 0;

                    for (var bi = 0; bi < 5; bi++)
                    {
                        for (int i = bj; i < bj + bvarray[bi]; i++)
                        {
                            if (bv.betList[i].money != null)
                            {
                                Regex regex = new Regex(@"^\+?[0-9]{1,10}[0][0]$|^$");
                                Match match = regex.Match(bv.betList[i].money.ToString());
                                if (!match.Success)
                                {
                                    ajd.ErrorMsg = "請勿竄改前端資料";
                                    ajd.isTrue   = false;
                                    throw new Exception("error");
                                }
                                if ((double)bv.betList[i].money <= 0)
                                {
                                    ajd.ErrorMsg = "請勿竄改前端資料";
                                    ajd.isTrue   = false;
                                    throw new Exception("error");
                                }


                                if (moneyclcik == 0)
                                {
                                    moneyclcik = (double)bv.betList[i].money;
                                }
                                if (moneyclcik != (double)bv.betList[i].money)
                                {
                                    ajd.ErrorMsg = "請勿竄改前端資料";
                                    ajd.isTrue   = false;
                                    throw new Exception("error");
                                }
                            }
                        }

                        if (bi < 4)
                        {
                            bj += 2;
                        }
                        else if (bi == 4)
                        {
                            bj += 4;
                        }
                        else
                        {
                            bj += 5;
                        }
                    }
                }
                double nabobMoney = 0;

                foreach (var b in bv.betList)
                {
                    if (!b.money.HasValue || b.money <= 0)
                    {
                        continue;
                    }
                    //bv.encryptedKey = System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"];
                    betDto bet = new betDto();;
                    bet.userId   = User.Identity.GetUserId();
                    bet.unitSn   = 1;
                    bet.comSn    = 1;
                    bet.money    = b.money;
                    bet.choiceSn = b.getChoiceSn(System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"]);

                    if (bet.choiceSn.HasValue)
                    {
                        topicDto t = await _game.GetTopicByChoiceSn(bet.choiceSn.Value);

                        if (t != null)
                        {
                            bet.topicSn = t.sn;
                        }
                    }
                    bet.gameSn = gd.sn;

                    if (Assets < bet.money)
                    {
                        ajd.ErrorMsg = "剩餘彩金不足";
                        ajd.isTrue   = false;
                        throw new Exception("error");
                    }
                    else
                    {
                        if (gd.betModel != 6)
                        {
                            Assets -= bet.money.Value;
                        }
                    }

                    /*if (!gd.canbet)
                     * {
                     *  ajd.ErrorMsg = "不可下注";
                     *  ajd.isTrue = false;
                     *  throw new Exception("error");
                     * }*/

                    foreach (topicDto t in gd.topicList)
                    {
                        if (t.choiceList.Where(p => p.sn == bet.choiceSn).Count() > 0)
                        {
                            bool canbet = (t.walk == 1) ? true : t.canbet;
                            //t.canbet = (t.walk == 1) ? true : t.canbet;
                            if (!canbet)
                            {
                                ajd.ErrorMsg = "不可預測";
                                ajd.isTrue   = false;
                                throw new Exception("error");
                            }
                        }
                    }
                    bet_list.Add(bet);
                }



                if (gd.betModel != 6)
                {
                    foreach (var bet in bet_list)
                    {
                        bool isTrue = await _game.CreateBet(bet);

                        if (isTrue)
                        {
                            ajd.isTrue = isTrue;
                        }
                        else
                        {
                            ajd.ErrorMsg = "系統錯誤,請重整後再重新預測";
                            throw new Exception("error");
                        }
                    }
                }
                else
                {
                    var betm = bet_list.Where(x => x.money != null).ToList();

                    bool isTrue = await _game.NabobCreateBet(betm);

                    if (isTrue)
                    {
                        ajd.isTrue = isTrue;
                    }
                    else
                    {
                        ajd.ErrorMsg = "系統錯誤,請重整後再重新預測";
                        throw new Exception("error");
                    }
                }


                if (ajd.isTrue)
                {
                    Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
                    new SignalRHelper().UpdateChoiceMoney(gd, encryptedKey, gd.md5GameSn);
                }
                else
                {
                    ajd.ErrorMsg = "魚骨幣發生問題,請重整後再重新預測";
                    throw new Exception("error");
                }

                return(Json(ajd));
            }
            catch
            {
                return(Json(ajd));
            }
        }
Exemplo n.º 11
0
        public async System.Threading.Tasks.Task <ActionResult> LottoCreate(betViewModel bv)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (!ModelState.IsValid)
                {
                    ajd.ErrorMsg = "";
                    foreach (var errs in ModelState.Values.Where(p => p.Errors.Count > 0).Select(p => p.Errors).Distinct())
                    {
                        foreach (var e in errs)
                        {
                            ajd.ErrorMsg += e.ErrorMessage + "\n";
                        }
                        //ajd.ErrorMsg += "";
                    }

                    ajd.isTrue = false;
                    throw new Exception("error");
                }

                if (!User.Identity.GetEmailConfirmed() && !User.Identity.GetPhoneNumberConfirmed())
                {
                    ajd.ErrorMsg = "預測前須先完成Email驗證以及手機驗證\n請先至會員中心進行Email驗證和手機驗證,謝謝";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }

                if (!User.Identity.GetEmailConfirmed())
                {
                    ajd.ErrorMsg = "預測前須先完成Email驗證\n請先至會員中心進行Email驗證,謝謝";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                if (!User.Identity.GetPhoneNumberConfirmed())
                {
                    ajd.ErrorMsg = "預測前須先完成手機驗證\n請先至會員中心進行手機驗證,謝謝";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }



                int?bvcount = 0;
                foreach (var bvlt in bv.betList)
                {
                    if (bvlt.strsn != "5")
                    {
                        bvcount += bvlt.count;
                    }
                }
                if (bvcount == 0)
                {
                    ajd.ErrorMsg = "請在填空單選擇一個以上的選項";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }

                double moneyclcik = 0;
                for (var bi = 0; bi < bv.betList.Count; bi++)
                {
                    if (bi == 0)
                    {
                        moneyclcik = (double)bv.betList[bi].money;
                    }
                    else
                    {
                        if (bv.betList[bi].money != moneyclcik)
                        {
                            ajd.ErrorMsg = "請勿竄改前端資料";
                            ajd.isTrue   = false;
                            throw new Exception("error");
                        }
                    }

                    Regex regex = new Regex(@"^\+?[0-9]{1,10}[0][0]$|^$");
                    Match match = regex.Match(bv.betList[bi].money.ToString());
                    if (!match.Success)
                    {
                        ajd.ErrorMsg = "請勿竄改前端資料";
                        ajd.isTrue   = false;
                        throw new Exception("error");
                    }
                }



                List <betDto>   bet_list      = new List <betDto>();
                GamesRepository _game         = new GamesRepository();
                int             firstChoiceSn = bv.betList.First().getChoiceSn(System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"]);
                gameDto         gd            = await _game.GetGameDetailByChoiceSn(firstChoiceSn);

                double Assets = new AssetsRepository().getAssetsByUserID(User.Identity.GetUserId(), 1);
                Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());

                //bv.encryptedKey = System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"];
                betDto bet = new betDto();
                bet.userId   = User.Identity.GetUserId();
                bet.unitSn   = 1;
                bet.comSn    = 1;
                bet.money    = bv.betList[0].money;
                bet.choiceSn = bv.betList[0].getChoiceSn(System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"]);
                if (bet.choiceSn.HasValue)
                {
                    topicDto t = await _game.GetTopicByChoiceSn(bet.choiceSn.Value);

                    if (t != null)
                    {
                        bet.topicSn = t.sn;
                    }
                }
                bet.gameSn = gd.sn;
                List <betCountDto> betlistmodel = new List <betCountDto>();
                foreach (var b in bv.betList)
                {
                    betCountDto betcount = new betCountDto();
                    betcount.betSn       = bet.choiceSn;
                    betcount.choiceStr   = b.strsn;
                    betcount.unitSn      = 1;
                    betcount.choiceCount = b.count;
                    betlistmodel.Add(betcount);
                }

                bet.betCount = betlistmodel;



                if (Assets < bet.money)
                {
                    ajd.ErrorMsg = "剩餘魚骨幣不足";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                else
                {
                    Assets -= bet.money.Value;
                }

                if (!gd.canbet)
                {
                    ajd.ErrorMsg = "不可預測";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }

                foreach (topicDto t in gd.topicList)
                {
                    if (t.choiceList.Where(p => p.sn == bet.choiceSn).Count() > 0)
                    {
                        if (!t.canbet)
                        {
                            ajd.ErrorMsg = "不可預測";
                            ajd.isTrue   = false;
                            throw new Exception("error");
                        }
                    }
                }



                bet_list.Add(bet);

                /* foreach (var b in bv.betList)
                 * {
                 *   if (!b.money.HasValue || b.money <= 0)
                 *       continue;
                 *   //bv.encryptedKey = System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"];
                 *   betDto bet = new betDto(); ;
                 *   bet.userId = User.Identity.GetUserId();
                 *   bet.unitSn = 1;
                 *   bet.comSn = 1;
                 *   bet.money = b.money;
                 *   bet.choiceSn = b.getChoiceSn(System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"]);
                 *   if (bet.choiceSn.HasValue)
                 *   {
                 *       topicDto t = await _game.GetTopicByChoiceSn(bet.choiceSn.Value);
                 *       if (t != null)
                 *       {
                 *           bet.topicSn = t.sn;
                 *       }
                 *   }
                 *   bet.gameSn = gd.sn;
                 *
                 *   if (Assets < bet.money)
                 *   {
                 *       ajd.ErrorMsg = "剩餘彩金不足";
                 *       ajd.isTrue = false;
                 *       throw new Exception("error");
                 *   }
                 *   else
                 *   {
                 *       Assets -= bet.money.Value;
                 *   }
                 *
                 *   if (!gd.canbet)
                 *   {
                 *       ajd.ErrorMsg = "不可下注";
                 *       ajd.isTrue = false;
                 *       throw new Exception("error");
                 *   }
                 *
                 *   foreach (topicDto t in gd.topicList)
                 *   {
                 *       if (t.choiceList.Where(p => p.sn == bet.choiceSn).Count() > 0)
                 *       {
                 *           if (!t.canbet)
                 *           {
                 *               ajd.ErrorMsg = "不可下注";
                 *               ajd.isTrue = false;
                 *               throw new Exception("error");
                 *           }
                 *       }
                 *   }
                 *   bet_list.Add(bet);
                 * }*/

                foreach (var betlist in bet_list)
                {
                    bool isTrue = await _game.CreateBet(betlist);

                    if (isTrue)
                    {
                        ajd.isTrue = isTrue;
                    }
                    else
                    {
                        ajd.ErrorMsg = "系統錯誤,請重整後再重新預測";
                        throw new Exception("error");
                    }
                }

                if (ajd.isTrue)
                {
                    Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
                    new SignalRHelper().UpdateChoiceMoney(gd, encryptedKey, gd.md5GameSn);
                }
                else
                {
                    ajd.ErrorMsg = "魚骨幣發生問題,請重整後再重新預測";
                    throw new Exception("error");
                }

                return(Json(ajd));
            }
            catch
            {
                return(Json(ajd));
            }
        }
Exemplo n.º 12
0
        public async System.Threading.Tasks.Task <aJaxDto> pays(StartBetReq sbr, byte?betmodel)
        {
            aJaxDto ajd = new aJaxDto();
            //HttpResponseMessage response = await client.PostAsJsonAsync("api/pays", sbr);
            HttpResponseMessage response;

            //5:龍的傳人 6:百萬大串燒 7:走地
            switch (betmodel)
            {
            case 5:
                response = await client.PostAsJsonAsync("api/dgnpays", sbr);

                break;

            case 6:
                response = await client.PostAsJsonAsync("api/nabobpays", sbr);

                break;

            case 7:
                response = await client.PostAsJsonAsync("api/Runpays", sbr);

                break;

            default:
                response = await client.PostAsJsonAsync("api/pays", sbr);

                break;
            }

            /* if (betmodel == 5)
             * {
             *   response = await client.PostAsJsonAsync("api/dgnpays", sbr);
             *
             * }
             * else if (betmodel == 6) {
             *   response = await client.PostAsJsonAsync("api/nabobpays", sbr);
             * }
             * else if(betmodel == 7)
             * {
             *   response = await client.PostAsJsonAsync("api/Runpays", sbr);
             * }
             * else {
             *  response = await client.PostAsJsonAsync("api/pays", sbr);
             * }*/

            if (response.IsSuccessStatusCode)
            {
                List <payoutDto> payoutList = await response.Content.ReadAsAsync <List <payoutDto> >();

                new AssetsRepository().AddAssetsByPay(payoutList);
                //更新pay值
                var gp = new GamePostsRepository().getgame(sbr.gameSn);
                gp.pay = 1;
                new GamePostsRepository().update(gp);

                response = await client.PostAsJsonAsync("api/setDone", sbr);

                if (response.IsSuccessStatusCode)
                {
                    ajd.isTrue = true;
                    await reflashGameListAsync();
                }
                else
                {
                    ajd.isTrue    = false;
                    ajd.ErrorCode = 500;
                    ajd.ErrorMsg  = response.Content.ReadAsAsync <string>().Result;
                }
            }
            else
            {
                ajd.isTrue    = false;
                ajd.ErrorCode = 500;
                ajd.ErrorMsg  = response.ReasonPhrase;
            }
            await reflashGameListAsync();

            return(ajd);
        }
        public async Task <ActionResult> _MallChange(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try {
                if (User.Identity.GetUserId() == null)
                {
                    ajd.ErrorMsg = "登入後才可以購買";
                    ajd.Title    = "未登入!";
                    ajd.isTrue   = true;
                    throw new Exception("error");
                }
                var user = UserManager.FindById(User.Identity.GetUserId());
                if (!user.EmailConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "Email尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                if (!user.PhoneNumberConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "手機尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                ProductApiModel pm = new ProductApiModel();

                Product product = new MallRepository().Get(id);
                // List<Product> productAll = new MallRepository().getAll();
                cfgUnit unit = new UnitsRepository().getValid(product.unitSn);

                pm.unit    = unit;
                pm.product = product;
                //pm.producList = productAll.Where(x => x.id < 5).ToList();
                int offer = 100;

                List <Preferential> pft = new PreferentialRepository().getAllvaild();
                ViewBag.offer = 100;
                if (pft != null)
                {
                    if (pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault() != null)
                    {
                        ViewBag.offer = pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                        offer         = (int)pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                    }

                    foreach (var pt in pft.Where(x => x.offerModel == 3))
                    {
                        if (pt.productId == id)
                        {
                            ViewBag.offer = pt.offer;
                            offer         = (int)pft.Where(x => x.offerModel == 3 && x.productId == id).FirstOrDefault().offer;
                        }
                    }
                }

                var gold = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()).Where(x => x.unitSn == product.unitSn).FirstOrDefault();
                ViewBag.gold   = (gold != null) ? gold.Asset : 0;
                ViewBag.change = (product.Price * offer / 100 > ViewBag.gold) ? 0 : 1;



                return(View(pm));
            }
            catch
            {
                //ajd.isTrue = false;
                return(Json(ajd, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult _FishPay(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (User.Identity.GetUserId() == null)
                {
                    ajd.ErrorMsg = "登入後才可以購買";
                    ajd.Title    = "未登入!";
                    ajd.isTrue   = true;
                    throw new Exception("error");
                }
                var user = UserManager.FindById(User.Identity.GetUserId());
                if (!user.EmailConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "Email尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                if (!user.PhoneNumberConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "手機尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }

                //var pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());

                //普通首儲

                /*if (pr == null)
                 * {
                 *  var prm = new PreferentialRecords {
                 *      UserId = User.Identity.GetUserId(),
                 *      Count = 1,
                 *      inpdate = DateTime.Now,
                 *      PreferentialID = 1
                 *  };
                 *
                 *  new PreferentialRepository().PRecordsCreate(prm);
                 *  pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());
                 * }*/
                var pr = new PreferentialRepository().getPRecordsAll(User.Identity.GetUserId()).Where(x => x.PreferentialID == 5);
                //2倍首儲
                if (pr.Count() == 0)
                {
                    var m = new MallRepository().getAll().Where(x => x.unitSn == 3 && x.type == 3).ToList();
                    foreach (var md in m)
                    {
                        var prm = new PreferentialRecords
                        {
                            UserId         = User.Identity.GetUserId(),
                            Count          = 1,
                            inpdate        = DateTime.Now,
                            PreferentialID = 5,
                            productID      = md.id
                        };

                        new PreferentialRepository().PRecordsCreate(prm);
                        //pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());
                    }
                }
                pr = new PreferentialRepository().getPRecordsAll(User.Identity.GetUserId()).Where(x => x.PreferentialID == 5);



                Product         product    = new MallRepository().Get(id);
                List <Product>  productAll = new MallRepository().getAll();
                cfgUnit         unit       = new UnitsRepository().getValid(product.unitSn);
                ProductApiModel pm         = new ProductApiModel();
                pm.unit       = unit;
                pm.product    = product;
                pm.producList = productAll.Where(x => x.unitSn == 3 && x.type == 3).ToList();

                List <int> fta = new List <int>();
                foreach (var p in pr)
                {
                    if (p.Count != 0)
                    {
                        fta.Add(1);
                    }
                    else
                    {
                        fta.Add(0);
                    }
                }
                pm.firstTypeArray = fta;
                if (pr.Where(x => x.Count != 0).Count() != 0)
                {
                    pm.firstType = 1;
                }
                else
                {
                    pm.firstType = 0;
                }
                //pm.firstType = (pr.Count != 0) ? 1 : 0;
                pm.preferential = new PreferentialRepository().getpreferential(1);
                return(View(pm));
            }
            catch
            {
                return(Json(ajd, JsonRequestBehavior.AllowGet));
            }
        }