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." }); }
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); }