public string Usertest(string user, int score)
        {
            AssetsViewModel avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()).Where(x => x.unitSn == 1).FirstOrDefault();

            avList.Asset -= score;
            return(avList.Asset.ToString());
        }
Exemplo n.º 2
0
        public ActionResult _getAssetsString()
        {
            List <AssetsViewModel> avList = new List <AssetsViewModel>();

            /* 每次都重新讀取
             * if (Session["Assets"]!=null)
             * {
             *  avList = ((List<AssetsViewModel>)Session["Assets"]);
             * }
             * else
             * {
             *  avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
             *  Session["Assets"] = avList;
             * }
             */
            avList            = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
            Session["Assets"] = avList;

            string returnstring = "";

            foreach (AssetsViewModel avm in avList)
            {
                returnstring += (returnstring == "" ? "" : " ");
                returnstring += avm.Asset;
            }
            return(View(avList));
        }
Exemplo n.º 3
0
 public ActionResult Entry(string pageId, string primaryKey, string formMode, string viewTitle, string purchaseObj)
 {
     try
     {
         ClearClientPageCache(Response);
         EntryModel model = new EntryModel();
         Repository.SetModel(primaryKey, formMode, model);
         SetParentEntryModel(pageId, primaryKey, formMode, viewTitle, model);
         SetThisEntryModel(model);
         if (formMode == "new" || formMode == "new2")
         {
             model.PurchaseTypeId = "PHT150425001";
             SetModelFromPurchase(model, purchaseObj);
         }
         else
         {
             AssetsRepository rep = new AssetsRepository();
             model.IsStartDepreciation = rep.GetStartDepreciationValue(primaryKey);
         }
         if (AppMember.ViewVersion == "Cus_Simple")
         {
             return(View("Cus_Simple_Entry", model));
         }
         else
         {
             return(View(model));
         }
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AssetsManageController.Entry get", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
     }
 }
        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 int MallChange(int id, float?money)
        {
            var userId = User.Identity.GetUserId();
            // var malldata = new MangerRepository().GetTransferRecords(userId);
            Product product = new MallRepository().Get(id);
            // 1 現金換魚骨 -2 兌獎 -3 鮭魚換魚骨

            ProductRecord assr = new ProductRecord
            {
                UserID    = User.Identity.GetUserId(),
                unitSn    = product.unitSn,
                assets    = (money != null) ? -money : -product.Price,
                inpdate   = DateTime.Now,
                type      = (money != null)?-3:-2,
                ProductId = product.id
            };
            bool aset = new AssetsRepository().AddBearByAssets(assr);

            if (product.unitSn == 2 && product.type == 3)
            {
                assr = new ProductRecord
                {
                    UserID    = User.Identity.GetUserId(),
                    unitSn    = 1,
                    assets    = money,
                    inpdate   = DateTime.Now,
                    type      = 1,
                    ProductId = product.id
                };
                aset = new AssetsRepository().AddBearByAssets(assr);
            }


            return(aset?1:0);
        }
Exemplo n.º 6
0
        public JsonResult SlottoLogin()
        {
            int          b      = 1;
            SlotVewModel slotvm = new SlotVewModel();

            if (User.Identity.GetUserId() == null)
            {
                b = 4;
            }
            else
            {
                List <AssetsViewModel> avList = new List <AssetsViewModel>();
                avList           = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
                slotvm.usermoney = avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset;


                var u = new H5GameRepository().Usercount(User.Identity.GetUserId()).Where(x => x.gameModel == 5).FirstOrDefault();
                if (u == null)
                {
                    DailyGameCount d = new DailyGameCount
                    {
                        userId    = User.Identity.GetUserId(),
                        gameModel = 5,
                        count     = 0
                    };
                    u = new H5GameRepository().DaycountCreate(d);
                }
                int r = new Random().Next(1, 14);
                slotvm.slotm = new H5GameRepository().GetSlotCash(r);
            }
            slotvm.loginUser = b;

            return(Json(slotvm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        //
        // GET: /Users/Edit/1
        public async Task <ActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var user = await UserManager.FindByIdAsync(id);

            if (user == null)
            {
                return(HttpNotFound());
            }

            var userRoles = await UserManager.GetRolesAsync(user.Id);

            List <AssetsViewModel> avList = new List <AssetsViewModel>();

            avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId(), 1);

            return(View(new EditUserViewModel()
            {
                Id = user.Id,
                Email = user.Email,
                RolesList = RoleManager.Roles.ToList().Select(x => new SelectListItem()
                {
                    Selected = userRoles.Contains(x.Name),
                    Text = x.Name,
                    Value = x.Name
                }),
                avList = avList
            }));
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid || !new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"]))
            {
                ViewData["Message"] = "驗證有誤,請重新登入";
                return(View(model));
            }

            // 這不會計算為帳戶鎖定的登入失敗
            // 若要啟用密碼失敗來觸發帳戶鎖定,請變更為 shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Name, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
                //Session["levelExp"] = new AssetsRepository().getExpByUserID(User.Identity.GetUserId());
                return(RedirectToAction("Index", "Manage"));

            //return RedirectToLocal(returnUrl);
            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                //ModelState.AddModelError("", "登入嘗試失試。");
                ViewData["Message"] = "登入嘗試失試。";
                return(View(model));
            }
        }
Exemplo n.º 9
0
        // GET: Html5
        public ActionResult AKGame()
        {
            List <AssetsViewModel> avList = new List <AssetsViewModel>();

            avList            = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
            Session["Assets"] = avList;
            ViewBag.Assets    = String.Format("{0:N1}", avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset);
            ViewBag.a         = avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset;
            var game = new H5GameRepository().H5GetAll(1).Where(x => x.gameStatus == 1).FirstOrDefault();

            ViewBag.EndTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", game.endTime);

            var h5 = new H5GameRepository().H5GetAll(1).Where(x => x.gameStatus != 1).LastOrDefault();
            //var akm = new List<AkGameVewModel>();
            AkGameVewModel ak = new AkGameVewModel();

            ak.gamenumberRecords = new H5GameRepository().GetNumberAll(h5.id);
            ViewBag.p            = ak.Brand;

            /* foreach (var h in h5.Where(x=>x.gameStatus!= 1))
             * {
             *   AkGameVewModel ak = new AkGameVewModel();
             *   ak.gamenumberRecords = new H5GameRepository().GetNumberAll(h.id);
             *
             *
             *   akm.Add(ak);
             * }
             *
             * ViewBag.p = akm.LastOrDefault().Brand;*/


            return(View(ak));
        }
Exemplo n.º 10
0
        public ActionResult ExportCard(string pageId, string primaryKey, string viewTitle)
        {
            try
            {
                System.Web.HttpContext curContext = System.Web.HttpContext.Current;
                curContext.Response.ContentType     = "application/vnd.ms-excel";
                curContext.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                curContext.Response.Charset         = "gb2312";

                AssetsRepository arep         = new AssetsRepository();
                DataSet          ds           = arep.GetAssetsCard(primaryKey);
                StringBuilder    sbHtml       = AssetsCardExcel.CreateCardExcel(ds);
                byte[]           fileContents = Encoding.GetEncoding("gb2312").GetBytes(sbHtml.ToString());
                string           fileName     = "AssetsCard" + ".xls";
                if (ds.Tables.Contains("Assets"))
                {
                    fileName = DataConvert.ToString(ds.Tables["Assets"].Rows[0]["assetsBarcode"]) + ".xls";
                }
                return(File(fileContents, "application/ms-excel", fileName));
            }
            catch (Exception ex)
            {
                AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AssetsManageController.ExportCard", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
                return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
            }
        }
Exemplo n.º 11
0
 public ActionResult BatchDelete(string pageId, string formMode, string viewTitle, string gridString, string isCascadeDelete)
 {
     try
     {
         UserInfo         sysUser  = CacheInit.GetUserInfo(HttpContext);
         AssetsRepository arep     = new AssetsRepository();
         DataUpdate       dbUpdate = new DataUpdate();
         try
         {
             dbUpdate.BeginTransaction();
             arep.DbUpdate = dbUpdate;
             arep.BatchDelete(sysUser, gridString, viewTitle, isCascadeDelete);
             dbUpdate.Commit();
             return(Content("1"));
         }
         catch (Exception)
         {
             dbUpdate.Rollback();
             return(Content(AppMember.AppText["DeleteExistRefrence"]));
         }
         finally
         {
             dbUpdate.Close();
         }
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AssetsManageController.BatchDelete post", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
     }
 }
Exemplo n.º 12
0
        public int LottoBets(int[] Number)
        {
            List <AssetsViewModel> avList = new List <AssetsViewModel>();

            avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
            int b = 1;

            //玩家扣錢記錄
            if (avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset >= 10000)
            {
                H5LottoBets h5b  = new H5LottoBets();
                var         game = new H5GameRepository().H5GetAll(2).Where(x => x.gameStatus == 1).FirstOrDefault();
                h5b.gameBets = new GameBets
                {
                    userId     = User.Identity.GetUserId(),
                    GameSn     = game.id,
                    unitSn     = 1,
                    money      = 10000,
                    Odds       = 12,
                    valid      = 1,
                    gameModel  = game.gameModel,
                    createDate = DateTime.Now,
                    modiDate   = DateTime.Now
                };
                List <PlayerNumber> pnvm = new List <PlayerNumber>();
                foreach (var n in Number)
                {
                    var pn = new PlayerNumber
                    {
                        Number = n
                    };
                    pnvm.Add(pn);
                }
                h5b.playnumber = pnvm;

                new H5GameRepository().LottoBets(h5b);


                AssetsRecord assr = new AssetsRecord
                {
                    UserId     = h5b.gameBets.userId,
                    unitSn     = 1,
                    gameSn     = h5b.gameBets.GameSn,
                    assets     = -10000,
                    type       = -15,
                    h5forValue = game.gameModel
                };

                new AssetsRepository().Addh5gameByAssets(assr);
            }
            else
            {
                b = 0;
            }


            return(b);
            //return Json(akm, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 13
0
        public static void BindAzureReposInMem(this IoC ioc)
        {
            var localHost = @"http://127.0.0.1:8998";

            ioc.Register <IClientAccountsRepository>(
                new ClientsRepository(
                    new AzureTableStorageLocal <ClientAccountEntity>(localHost, "Clients"), new AzureTableStorageLocal <AzureIndex>(localHost, "Clients")));

            ioc.Register <IPersonalDataRepository>(
                new PersonalDataRepository(new AzureTableStorageLocal <PersonalDataEntity>(localHost, "PersonalData")));

            ioc.Register <IKycRepository>(
                new KycRepository(new AzureTableStorageLocal <KycEntity>(localHost, "KycRepository")));


            ioc.Register <IKycDocumentsRepository>(
                new KycDocumentsRepository(new AzureTableStorageLocal <KycDocumentEntity>(localHost, "KycDocumentsRepository")));

            ioc.Register <IKycDocumentsScansRepository>(
                new KycDocumentsScansRepository(new AzureBlobLocal(localHost)));

            ioc.Register <IKycUploadsLog>(
                new KycUploadsLog(new AzureTableStorageLocal <KycUploadsLogItemEntity>(localHost, "KycUploadsLog")));

            ioc.Register <IBalanceRepository>(
                new BalanceRepository(new AzureTableStorageLocal <TraderBalanceEntity>(localHost, "BalanceRepository")));

            ioc.Register <IIdentityGenerator>(
                new IdentityGenerator(new AzureTableStorageLocal <IdentityEntity>(localHost, "IdentityGenerator")));

            ioc.Register <IOrdersRepository>(
                new OrdersRepository(new AzureTableStorageLocal <OrderEntity>(localHost, "OrdersRepository")));

            ioc.Register <IClientSettingsRepository>(
                new ClientSettingsRepository(new AzureTableStorageLocal <ClientSettingsEntity>(localHost, "ClientSettingsRepository")));

            var assetsRepositry = new AssetsRepository(new AzureTableStorageLocal <AssetEntity>(localHost, "AssetsRepository"));

            assetsRepositry.PopulateAssets();
            ioc.Register <IAssetsRepository>(assetsRepositry);

            var assetPairsRepository = new AssetPairsRepository(new AzureTableStorageLocal <AssetPairEntity>(localHost, "AssetPairsRepository"));

            assetPairsRepository.PopulateAssetPairsRepository();
            ioc.Register <IAssetPairsRepository>(assetPairsRepository);

            ioc.Register <IBrowserSessionsRepository>(
                new BrowserSessionsRepository(new AzureTableStorageLocal <BrowserSessionEntity>(localHost, "BrowserSessionsRepository")));

            ioc.Register <IMenuBadgesRepository>(
                new MenuBadgesRepository(new AzureTableStorageLocal <MenuBadgeEntity>(localHost, "MenuBadgesRepository")));


            ioc.Register <IAccountsRepository>(
                new AccountsRepository(new AzureTableStorageLocal <AccountEntity>(localHost, "Accounts")));

            ioc.Register <IPinSecurityRepository>(
                new PinSecurityRepository(new AzureTableStorageLocal <PinSecurityEntity>(localHost, "ClientPins")));
        }
 public BridgeMeshBuilder(AssetsRepository repo, DynamicAssetsFactory factory)
 {
     this.repo = repo;
     this.factory = factory;
     plank = repo.LoadMesh("SkyMerchant\\Bridge\\BridgePartPlank");
     rope = repo.LoadMesh("SkyMerchant\\Bridge\\BridgePartRope");
     stick = repo.LoadMesh("SkyMerchant\\Bridge\\BridgePartStick");
 }
Exemplo n.º 15
0
        public static void BindAzureReposInMemForTests(this IoC ioc)
        {
            ioc.Register <IClientAccountsRepository>(
                new ClientsRepository(
                    new NoSqlTableInMemory <ClientAccountEntity>(), new NoSqlTableInMemory <AzureIndex>()));

            ioc.Register <IPersonalDataRepository>(
                new PersonalDataRepository(new NoSqlTableInMemory <PersonalDataEntity>()));

            ioc.Register <IKycRepository>(
                new KycRepository(new NoSqlTableInMemory <KycEntity>()));


            ioc.Register <IKycDocumentsRepository>(
                new KycDocumentsRepository(new NoSqlTableInMemory <KycDocumentEntity>()));

            ioc.Register <IKycDocumentsScansRepository>(
                new KycDocumentsScansRepository(new AzureBlobInMemory()));

            ioc.Register <IKycUploadsLog>(
                new KycUploadsLog(new NoSqlTableInMemory <KycUploadsLogItemEntity>()));

            ioc.Register <IBalanceRepository>(
                new BalanceRepository(new NoSqlTableInMemory <TraderBalanceEntity>()));

            ioc.Register <IIdentityGenerator>(
                new IdentityGenerator(new NoSqlTableInMemory <IdentityEntity>()));

            ioc.Register <IOrdersRepository>(
                new OrdersRepository(new NoSqlTableInMemory <OrderEntity>()));

            ioc.Register <IClientSettingsRepository>(
                new ClientSettingsRepository(new NoSqlTableInMemory <ClientSettingsEntity>()));

            var assetsRepositry = new AssetsRepository(new NoSqlTableInMemory <AssetEntity>());

            assetsRepositry.PopulateAssets();
            ioc.Register <IAssetsRepository>(assetsRepositry);

            var assetPairsRepository = new AssetPairsRepository(new NoSqlTableInMemory <AssetPairEntity>());

            assetPairsRepository.PopulateAssetPairsRepository();
            ioc.Register <IAssetPairsRepository>(assetPairsRepository);

            ioc.Register <IBrowserSessionsRepository>(
                new BrowserSessionsRepository(new NoSqlTableInMemory <BrowserSessionEntity>()));

            ioc.Register <IMenuBadgesRepository>(
                new MenuBadgesRepository(new NoSqlTableInMemory <MenuBadgeEntity>()));


            ioc.Register <IAccountsRepository>(
                new AccountsRepository(new NoSqlTableInMemory <AccountEntity>()));

            ioc.Register <IPinSecurityRepository>(
                new PinSecurityRepository(new NoSqlTableInMemory <PinSecurityEntity>()));
        }
Exemplo n.º 16
0
        public ActionResult AkAssets()
        {
            List <AssetsViewModel> avList = new List <AssetsViewModel>();

            avList            = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
            Session["Assets"] = avList;
            ViewBag.Assets    = String.Format("{0:N1}", avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset);
            ViewBag.a         = avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset;
            return(View());
        }
Exemplo n.º 17
0
        public int AKBets(float money, int Number)
        {
            H5Bets h5b  = new H5Bets();
            var    game = new H5GameRepository().H5GetAll(1).Where(x => x.gameStatus == 1).FirstOrDefault();

            h5b.gameBets = new GameBets {
                userId     = User.Identity.GetUserId(),
                GameSn     = game.id,
                unitSn     = 1,
                money      = money,
                Odds       = 12,
                valid      = 1,
                gameModel  = game.gameModel,
                createDate = DateTime.Now,
                modiDate   = DateTime.Now
            };
            h5b.playnumber = new PlayerNumber {
                Number = Number
            };
            new H5GameRepository().AkBets(h5b);
            int b = 1;
            List <AssetsViewModel> avList = new List <AssetsViewModel>();

            avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());

            //玩家扣錢記錄
            if (avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset >= money)
            {
                AssetsRecord assr = new AssetsRecord
                {
                    UserId     = h5b.gameBets.userId,
                    unitSn     = 1,
                    gameSn     = h5b.gameBets.GameSn,
                    assets     = -(double)money,
                    type       = -15,
                    h5forValue = game.gameModel
                };

                new AssetsRepository().Addh5gameByAssets(assr);
            }
            else
            {
                b = 0;
            }


            return(b);
            //return Json(akm, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 18
0
        public async Task <ActionResult> _BetsByUserIDPhone()
        {
            string              UserID  = User.Identity.GetUserId();
            List <BetListDto>   BetList = await new BetsRepository().BetsByUserID(UserID);
            GamePostsRepository _gpr    = new GamePostsRepository();
            List <GamePosts>    gpList  = _gpr.getValidAll();
            double              assets  = new AssetsRepository().getAssetsByUserID(UserID, 1);

            foreach (var b in BetList)
            {
                if (b.isTrueValue == "true")
                {
                    if (b.betModel == 2)
                    {
                        b.showTitle = "題目總獎金 " + b.topicMoney + " × 預測金額 " + b.money + " ÷ 正解總獎金 " + b.choiceMoney;
                        if (b.rake > 0)
                        {
                            b.showTitle += " × (100-" + b.rake + ")%";
                        }
                        b.showTitle += "=" + b.realmoney;
                    }
                    else if (b.betModel == 1)
                    {
                        b.showTitle = "預測金額 " + b.money + " × 倍率 " + b.Odds + " = " + b.realmoney;
                    }
                }
            }
            BetsByUserID bbui = new BetsByUserID();

            /*foreach (var bl in BetList)
             * {
             *  BetListDto blvm = new BetListDto();
             *  blvm.gamepostsn  = gpList.Where(p => p.GameSn == bl.gameSn).FirstOrDefault().sn;
             *  //bbui.gamepostsn = gpList.Where(p => p.GameSn == bl.gameSn).FirstOrDefault().sn;
             *  BetList.Add(blvm);
             * }*/



            // BetsByUserID bbui = new BetsByUserID();
            bbui.BetList = BetList.OrderByDescending(p => p.betDatetime).ToList();
            bbui.assets  = new AssetsRepository().getAssetsByUserID(UserID, 1);

            return(View(bbui));
        }
Exemplo n.º 19
0
        public int BricktoCount()
        {
            //1:沒問題 4:沒登入 5:沒錢 0:沒每日
            int b = 1;

            if (User.Identity.GetUserId() != null)
            {
                var u = new H5GameRepository().Usercount(User.Identity.GetUserId()).Where(x => x.gameModel == 4).FirstOrDefault();
                if (u == null && User.Identity.GetUserId() != null)
                {
                    DailyGameCount d = new DailyGameCount
                    {
                        userId    = User.Identity.GetUserId(),
                        gameModel = 4,
                        count     = 5
                    };
                    u = new H5GameRepository().DaycountCreate(d);
                }

                List <AssetsViewModel> avList = new List <AssetsViewModel>();
                avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());

                if (avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset < 200)
                {
                    b = 5;
                }



                if (u.count == 0)
                {
                    b = 0;
                }
            }
            else
            {
                b = 4;
            }



            return(b);
        }
Exemplo n.º 20
0
        //[ValidateAntiForgeryToken]
        //擴充程式
        public async Task <string> LoginExtensions(LoginViewModel model, string returnUrl)
        {
            // 這不會計算為帳戶鎖定的登入失敗
            // 若要啟用密碼失敗來觸發帳戶鎖定,請變更為 shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Name, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
                //Session["levelExp"] = new AssetsRepository().getExpByUserID(User.Identity.GetUserId());
                return("success");

            //return RedirectToLocal(returnUrl);
            case SignInStatus.LockedOut:
            //return View("Lockout");
            case SignInStatus.RequiresVerification:
            //return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "登入嘗試失試。");
                return("error");
            }
        }
Exemplo n.º 21
0
 public JsonResult GetDefaultByAssetsClass(string assetsClassId)
 {
     try
     {
         ClearClientPageCache(Response);
         DataRow          dr            = Repository.GetModel(assetsClassId);
         string           assetsClassNo = DataConvert.ToString(dr["assetsClassNo"]);
         AssetsRepository arep          = new AssetsRepository();
         var selectList = new
         {
             remainRate       = DataConvert.ToDouble(dr["RemainRate"]),
             durableYears     = DataConvert.ToInt32(dr["durableYears"]),
             unitId           = DataConvert.ToString(dr["unitId"]),
             depreciationType = DataConvert.ToString(dr["depreciationType"]),
             assetsBarcode    = arep.GetAssetsBarcode(assetsClassNo)
         };
         return(Json(selectList, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AssetsClassController.GetDefaultByAssetsClass", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(new JsonResult());
     }
 }
Exemplo n.º 22
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl, int?log)
        {
            if (!ModelState.IsValid || !new reCAPTCHAHelper().Validate(Request["g-recaptcha-response"]))
            {
                ViewData["Message"] = "驗證有誤,請重新登入";
                return(View(model));
            }

            // 這不會計算為帳戶鎖定的登入失敗
            // 若要啟用密碼失敗來觸發帳戶鎖定,請變更為 shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Name, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                var live = new UserRepository().getlive();
                var user = UserManager.FindByName(model.Name);

                foreach (var l in live)
                {
                    if (l.username == user.Id)
                    {
                        if (l.valid != 0)
                        {
                            ViewData["Message"] = "此為直播主帳號,無法登入。";
                            return(View(model));
                        }
                        else
                        {
                            ViewData["Message"] = "此帳號還在申請審核中。";
                            return(View(model));
                        }
                    }
                }
                string vClientIP = GetIPAddress();

                new UserRepository().CreateIP(user.Id, vClientIP);

                PreferentialRecords pr = new PreferentialRepository().getPRecordsType(user.Id, 100);



                Session["Assets"] = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId());
                //Session["levelExp"] = new AssetsRepository().getExpByUserID(User.Identity.GetUserId());
                if (returnUrl != null)
                {
                    Response.Redirect(returnUrl);
                }

                if (pr == null && log == 1)
                {
                    var prm = new PreferentialRecords
                    {
                        UserId         = user.Id,
                        Count          = 0,
                        inpdate        = DateTime.Now,
                        PreferentialID = 100
                    };

                    new PreferentialRepository().PRecordsCreate(prm);
                    var ar = new AssetsRecord
                    {
                        UserId  = user.Id,
                        unitSn  = 1,
                        assets  = 5000,
                        type    = 2,
                        inpdate = DateTime.Now
                    };
                    new AssetsRepository().AddAssetsByAssets(ar);
                    return(RedirectToAction("Index", "Manage", new { Log = "已贈送5000魚骨幣至您的帳戶" }));
                }

                return(RedirectToAction("Index", "Home"));


            //return RedirectToLocal(returnUrl);
            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                //ModelState.AddModelError("", "登入嘗試失試。");
                ViewData["Message"] = "登入嘗試失試。";
                return(View(model));
            }
        }
Exemplo n.º 23
0
 public ListModel()
 {
     Repository = new AssetsRepository();
 }
Exemplo n.º 24
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.º 25
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.º 26
0
 public EntryModel()
 {
     BaseRepository = new AssetsRepository();
 }
        public int MallChange(int id, float?money, string name, string phone, string address)
        {
            var userId = User.Identity.GetUserId();
            // var malldata = new MangerRepository().GetTransferRecords(userId);
            Product product = new MallRepository().Get(id);
            // 1 現金換魚骨 -2 兌獎 -3 鮭魚換魚骨

            int offer = 100;

            List <Preferential> pft = new PreferentialRepository().getAllvaild();

            if (pft != null)
            {
                if (pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault() != null)
                {
                    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)
                    {
                        offer = (int)pft.Where(x => x.offerModel == 3 && x.productId == id).FirstOrDefault().offer;
                    }
                }
            }

            ProductRecord assr = new ProductRecord
            {
                UserID    = User.Identity.GetUserId(),
                unitSn    = product.unitSn,
                assets    = (money != null) ? -money : -product.Price * offer / 100,
                inpdate   = DateTime.Now,
                type      = (money != null)?-3:-2,
                ProductId = product.id,
                recipient = name,
                phone     = phone,
                address   = address
            };
            bool aset = new AssetsRepository().AddBearByAssets(assr);

            if (product.unitSn == 2 && product.type == 3)
            {
                assr = new ProductRecord
                {
                    UserID    = User.Identity.GetUserId(),
                    unitSn    = 1,
                    assets    = money * product.Price,
                    inpdate   = DateTime.Now,
                    type      = 3,
                    ProductId = product.id,
                    recipient = name,
                    phone     = phone,
                    address   = address
                };
                aset = new AssetsRepository().AddBearByAssets(assr);
            }
            if (money == null)
            {
                var m = Math.Ceiling((double)product.Price / 1.2 / 30000 * 30);
                var d = 0;
                if (m < 1000)
                {
                    d = 1;
                }
                else if (999 < m && m < 20000)
                {
                    d = 2;
                }
                else if (m > 19999)
                {
                    d = 3;
                }
                var    user         = UserManager.FindById(User.Identity.GetUserId());
                var    content      = ConfirmChange(d, assr, product);
                var    EmailContent = EmailTemplatesService.GetChangeEmailHTML(content);
                var    h            = Server.MapPath("\\Content\\Pdf\\Change\\");
                string url          = (product.pdf_file != null) ?  product.pdf_file : "";
                new MailServiceMailgun().ChangeSend("熊i猜兌獎通知信", EmailContent, user.Email, url);
            }



            return(aset?1:0);
        }
Exemplo n.º 28
0
 protected override IApproveMasterFactory CreateRepository()
 {
     Repository = new AssetsRepository();
     return(new ApproveMasterRepositoryFactory <AssetsRepository>(Repository));
 }
        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));
            }
        }