コード例 #1
0
        public async Task <IActionResult> Deposit(NewDepositViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Deposit", "Transaction"));
            }

            var user = await userManager.GetUserAsync(HttpContext.User);

            var userCards = await this.cardService.GetSelectListCards(user);

            var userDeposit = await this.transactionService.MakeDeposit(user, (int)model.CreditCardId, (int)model.Amount);

            var convertedAmount = await this.walletService.ConvertBalance(user);

            return(Json(new { Balance = convertedAmount }));
        }
コード例 #2
0
        public async Task <IActionResult> Withdraw(NewDepositViewModel model)
        {
            var user = await userManager.GetUserAsync(HttpContext.User);

            var oldWallet = await this.walletService.GetUserWallet(user);

            if (!ModelState.IsValid || (Math.Round(oldWallet.Balance, 2) < Math.Round((decimal)model.Amount, 2)))
            {
                return(RedirectToAction("Deposit", "Transaction"));
            }

            var withdrawedAmount = await this.walletService.WithdrawFromUserBalance(user, (int)model.Amount, (int)model.CreditCardId);

            var convertedAmount = await this.walletService.ConvertBalance(user);

            return(Json(new { Balance = convertedAmount }));
        }
コード例 #3
0
        public async Task <IActionResult> Deposit(string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;

            var user = await userManager.GetUserAsync(HttpContext.User);

            var userCards = await this.cardService.GetSelectListCards(user);

            var userCardsForDelete = await this.cardService.GetSelectListCards(user);

            var userWallet = await this.walletService.GetUserWallet(user);

            var model = new NewDepositViewModel();

            model.CardCurrencySymbol = userWallet.CurrencySymbol;
            model.Cards          = userCards.ToList();
            model.CardsForDelete = userCardsForDelete.ToList();

            return(View(model));
        }