public UserAccount(ATMViewModel atm, LoginWindow loginWindow) { InitializeComponent(); this.ATM = atm; DataContext = this.ATM; this.LoginWindow = loginWindow; }
public async Task <IActionResult> ATM() { var vm = new ATMViewModel(); vm.Customer = await _context.GetCustomerWithAccounts(CustomerId); return(View(vm)); }
public LoginWindow() { InitializeComponent(); valid = new LoginValidator(); DataContext = valid; atm = new ATMViewModel(); account = new UserAccount(atm, this); }
public IActionResult Index(string accountNumber = "", decimal amount = 0) { ATMViewModel model = new ATMViewModel() { Amount = amount, AccountNumber = accountNumber }; return(View(model)); }
public AuthorizationPage(ATMViewModel atmViewModel) { InitializeComponent(); DataContext = atmViewModel; PasswordBox.Focus(); // atmViewModel.AuthorizationSucceeded += () => Helper.Event(() => NavigationService.Navigate(new MainMenu(atmViewModel))); // atmViewModel.AuthorizationSucceeded += () => Dispatcher.BeginInvoke(new ThreadStart(() => NavigationService.Navigate(new MainMenuPage(atmViewModel)))); // atmViewModel.AuthorizationSucceeded += () => Dispatcher.Invoke(() => NavigationService.Navigate(new MainMenuPage(atmViewModel))); // atmViewModel.AuthorizationSucceeded += () => NavigationService.Navigate(new MainMenuPage(atmViewModel)); // atmViewModel.AuthorizationFailed += message => MessageBox.Show(message); }
public MainWindow() { InitializeComponent(); var atmViewModel = new ATMViewModel(); atmViewModel.AuthorizationSucceeded += () => Dispatcher.Invoke(() => Frame.NavigationService.Navigate(new MainMenuPage(atmViewModel))); atmViewModel.AuthorizationFailed += message => MessageBox.Show(message); atmViewModel.TransferSucceeded += () => Dispatcher.Invoke(() => { MessageBox.Show("Успешный перевод"); Frame.NavigationService.Navigate(new MainMenuPage(atmViewModel)); }); atmViewModel.TransferFailed += message => Dispatcher.Invoke(() => { MessageBox.Show(message); Frame.NavigationService.Navigate(new MainMenuPage(atmViewModel)); }); Frame.NavigationService.Navigate(new StartPage(atmViewModel)); Closing += (s, e) => Environment.Exit(0); }
public BalancePage(ATMViewModel atmViewModel) { InitializeComponent(); DataContext = atmViewModel; }
public async Task <IActionResult> ATM(ATMViewModel vm) { vm.Account = await _context.GetAccountWithTransactions(CustomerId, vm.AccountId); if (vm.Account == null) { ModelState.AddModelError("AccountInvalid", "Account not found"); goto ErrorCleanup; } switch (vm.TransactionType) { case TransactionType.Deposit: var depositResult = vm.doDeposit(); switch (depositResult.transactionResult) { case TransactionResult.OK: _context.CreateTransaction(depositResult.transaction); break; case TransactionResult.FAIL_BELOW_ZERO: ModelState.AddModelError(nameof(vm.Amount), "Amount must be above 0"); goto ErrorCleanup; case TransactionResult.FAIL_EXTRA_DIGITS: ModelState.AddModelError(nameof(vm.Amount), "More than 2 decimal places used."); goto ErrorCleanup; default: break; } break; case TransactionType.Withdrawal: var withdrawResult = vm.doWithdraw(); switch (withdrawResult.transactionResult) { case TransactionResult.OK: _context.CreateTransaction(withdrawResult.transaction); if (withdrawResult.serviceCharge != null) { //attach previous transactionId to unused Comment field //this value will be formatted and printed out correctly by the view withdrawResult.serviceCharge.Comment += withdrawResult.transaction.TransactionId; _context.CreateTransaction(withdrawResult.serviceCharge); } break; case TransactionResult.FAIL_BELOW_ZERO: ModelState.AddModelError(nameof(vm.Amount), "Amount must be above 0"); goto ErrorCleanup; case TransactionResult.FAIL_INSUFFICIENT_FUNDS: ModelState.AddModelError(nameof(vm.Amount), "Not enough money to withdraw."); goto ErrorCleanup; case TransactionResult.FAIL_EXTRA_DIGITS: ModelState.AddModelError(nameof(vm.Amount), "More than 2 decimal places used."); goto ErrorCleanup; default: break; } break; case TransactionType.Transfer: vm.TargetAccount = await _context.GetAccount(CustomerId, vm.TargetAccountId); if (vm.TargetAccount == null) { ModelState.AddModelError(nameof(vm.TargetAccountId), "Destination account must be set for transfers"); goto ErrorCleanup; } if (vm.AccountId == vm.TargetAccountId) { ModelState.AddModelError(nameof(vm.TargetAccountId), "Source and destination account cannot be the same"); goto ErrorCleanup; } var transferResult = vm.doTransfer(); switch (transferResult.transactionResult) { case TransactionResult.OK: _context.CreateTransaction(transferResult.transaction); if (transferResult.serviceCharge != null) { //include previous transactionId in comment transferResult.serviceCharge.Comment += transferResult.transaction.TransactionId; _context.CreateTransaction(transferResult.serviceCharge); } break; case TransactionResult.FAIL_BELOW_ZERO: ModelState.AddModelError(nameof(vm.Amount), "Amount must be above 0."); goto ErrorCleanup; case TransactionResult.FAIL_INSUFFICIENT_FUNDS: ModelState.AddModelError(nameof(vm.Amount), "Not enough money to withdraw."); goto ErrorCleanup; case TransactionResult.FAIL_EXTRA_DIGITS: ModelState.AddModelError(nameof(vm.Amount), "More than 2 decimal places used."); goto ErrorCleanup; default: break; } break; default: ModelState.AddModelError(nameof(vm.TransactionType), "Invalid transaction type specified"); break; } TempData["successMessage"] = "Transaction successful."; return(RedirectToAction(nameof(Accounts))); ErrorCleanup: //set fields that weren't included in the POST so we can redirect safely vm.Customer = await _context.GetCustomerWithAccounts(CustomerId); return(View(vm)); }
public MainMenuPage(ATMViewModel atmViewModel) { InitializeComponent(); DataContext = atmViewModel; }
public TransferPage(ATMViewModel atmViewModel) { InitializeComponent(); DataContext = atmViewModel; }
public ATMWindow(IndividualAccount account) { InitializeComponent(); DataContext = new ATMViewModel(account); }