public IActionResult UserWallets() { int userId = int.Parse(_userService.GetUserId(User)); var model = new UserWalletsViewModel(); var registrant = _registrantService.GetRegistrantByUserId(userId, includeWallets: true); if (registrant == null) { //model.Message = "Please enter personal info before attempting to request a new wallet!"; return(Redirect("/Identity/Account/Manage/PersonalData")); } foreach (var wallet in registrant.Wallets) { wallet.Accounts = _accountService.GetAllAccountsWithWalledId(wallet.Id).ToList(); } model.Wallets = _mapper.Map <List <UserWallets> >(registrant.Wallets); for (int i = 0; i < registrant.Wallets.Count; i++) { model.Wallets[i].Verified = registrant.Wallets[i].IsVerified ? "Yes" : "No"; model.Wallets[i].RowId = "RowGroup" + i; model.Wallets[i].Heading = "Heading" + i; } return(View(model)); }
public IActionResult Transaction(UserWalletsViewModel input) { var model = TempData.Get <UserWalletsViewModel>("Model"); if (ModelState.IsValid) { var sender = _accountService.GetAccountById(input.InputTransaction.FromAccountWithId); if (sender == null) { model.Message = "Error, account does not exist, please try again!"; return(View("UserWallets", model)); } // is the senders balance sufficient if (sender.Balance <= input.InputTransaction.Amount) { model.Message = "Error, insufficient funds in account!"; return(View("UserWallets", model)); } var recipient = _accountService.GetAccountByIBAN(input.InputTransaction.ToIBAN);//(input.InputTransaction.ToIBAN); if (recipient != null) { if (sender.Id == recipient.Id) { model.Message = "Error, can't send money to same account!"; return(View("UserWallets", model)); } } int currentUserId = int.Parse(_userService.GetUserId(User)); _financialTransactionService.EnactTransaction(sender, input.InputTransaction.Amount, currentUserId, input.InputTransaction.ToIBAN, recipient); return(RedirectToAction("UserWallets")); } return(View("UserWallets", model)); }