Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            sales.Sales         = Sales.AllStats();
            gameList.Games      = Game.ReviewGames();
            gameList.AddButtons = true;


            var service = new CreditWebService.CreditWebService();

            bankAccount = service.GetBankAccount(3);
            TransactionHistory.DataSource = service.TransactionHistoryOf(bankAccount);
            TransactionHistory.DataBind();
            BalanceLabel.Text = "$" + bankAccount.Balance;

            List <CreditCardDto> cards = service.GetCardsForAccount(3).ToList();

            CreditCardRepeater.DataSource = cards;
            CreditCardRepeater.DataBind();
        }
Пример #2
0
        protected void PayButton_OnClick(object sender, EventArgs e)
        {
            var user = (User)Session["user"];

            if (user == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (!UseBalance.Checked)
            {
                var service = new CreditWebService.CreditWebService();
                var details = new CreditCardDto
                {
                    CardNumber            = cardnumber.Text.Replace(" ", ""),
                    CardVerificationValue = securitycode.Text,
                    Month = int.Parse(expirationdate.Text.Substring(0, 2)),
                    Year  = 2000 + int.Parse(expirationdate.Text.Substring(3, 2))
                };

                var transaction = service.Pay(details, service.GetBankAccount(3), amount);
                if (transaction == null)
                {
                    SnackbarHelper.DisplaySnackBar(this, "Payment Failed");
                    return;
                }
            }
            else
            {
                user.UpdateBalance(user.Balance - amount);
            }

            string paymentSuccessPage = "./PaymentSuccess.aspx";
            var    queryString        = HttpUtility.ParseQueryString(string.Empty);

            switch (payingFor)
            {
            case "bal":
                user.UpdateBalance(amount + user.Balance);
                queryString.Add("balance", "" + amount);
                break;

            case "game":
                if (BuyGift.Checked)
                {
                    var code        = GameCode.GenerateCode(game.Id);
                    var codeEncoded = EncodingHelper.Base64Encode(code.Code);
                    queryString.Add("code", HttpUtility.UrlEncode(codeEncoded));
                }
                else
                {
                    UserGame.AddGame(user.Id, game.Id, amount);
                    queryString.Add("game", "" + game.Id);
                    user.AddActivity("Bought " + game.GameName);
                }

                break;
            }


            Response.Redirect(paymentSuccessPage + "?" + queryString);
        }