コード例 #1
0
        public JsonResult LoadCard(LoadCardViewModel loadCardViewModel)
        {
            if (!ModelState.IsValid)
            {
                return Json(new { Result = "Fail", Message = "Input data is not valid." });
            }

            TransactionType transactionType = _transactionTypeRepository.GetTransactionTypeByName("AccountToCard");
            string note = "Loading funds from account to card";
            Account account = _accountRepository.GetAccountById(loadCardViewModel.AccountId);
            int currencyId = _balanceRepository.GetBalanceById(account.BalanceId).CurrencyId;
            double comissionAmount = loadCardViewModel.Amount * transactionType.ComissionPercent / 100;
            string status = "Success";

            try
            {
                _transactionRepository.ProcessLoadingFundsToCard(loadCardViewModel.AccountId, loadCardViewModel.CardId, loadCardViewModel.Amount, 
                    transactionType.Id, note, currencyId, comissionAmount, status);
            }
            catch
            {
                return Json(new { Result = "Fail", Message = "There was an error while processing the transaction." });
            }

            return Json(new { Result = "Success", Message = "The card has been loaded." });
        }
コード例 #2
0
        public ActionResult LoadCard()
        {
            string userId = User.Identity.GetUserId();
            Customer customer = _customerRepository.GetCustomerByUserId(userId);

            LoadCardViewModel loadCardViewmodel = new LoadCardViewModel();
            loadCardViewmodel.Accounts = _accountRepository.GetAllAccountsByCustomerId(customer.Id).Select(a => new SelectListItem { Text = a.AccountNumber, Value = a.Id.ToString() });
            loadCardViewmodel.Cards = new List<SelectListItem>{new SelectListItem { Text = "Please, choose a card", Value = "0"}};
            return View(loadCardViewmodel);
        }