/// <summary> /// Checks the pin. /// </summary> /// <param name="pin">The pin.</param> private async void CheckPin(IWrappedValue <string> pin) { var result = await _service.ValidatePin(_provider.GetBankCardNumber(), pin.Value); _dispatcherAccessor.Dispatcher.Invoke(() => { if (result) { // store entered value in context. _provider.CurrentPin = pin.Value; // reset entered value on UI pin.Value = null; // navigate to actions _regionManager.RequestNavigate(RegionName.MainRegion, ViewName.ActionsView); ErrorMessage = null; } else { ErrorMessage = "Invalid PIN"; } }); }
/// <summary> /// Requests the balance. /// </summary> private async void RequestBalance() { Balance = "Please wait for a while..."; var result = await _service.GetBalance(_provider.GetBankCardNumber(), _provider.CurrentPin); _dispatcherAccessor.Dispatcher.Invoke(() => Balance = result); }
/// <summary> /// Changed the pin. /// </summary> /// <param name="newPin">The pin.</param> private async void ChangePin(IWrappedValue <string> newPin) { if (string.IsNullOrWhiteSpace(newPin.Value) || newPin.Value.Length != 4) { ErrorMessage = "Invalid PIN code specified"; } var result = await _service.ChangePin(_provider.GetBankCardNumber(), _provider.CurrentPin, newPin.Value); _dispatcherAccessor.Dispatcher.Invoke( () => { if (result) { // store in context _provider.CurrentPin = newPin.Value; // reset on UI newPin.Value = null; // navigate to actions _regionManager.RequestNavigate(RegionName.MainRegion, ViewName.ActionsView); ErrorMessage = null; newPin.Value = null; } else { ErrorMessage = "PIN was not changed."; newPin.Value = null; } }); }
/// <summary> /// Withdraws the specified cache. /// </summary> private async void Withdraw() { if (Amount <= 0) { ErrorMessage = "Please specify an amount"; Amount = 0; return; } var errorMessage = await _service.Withdraw(_provider.GetBankCardNumber(), _provider.CurrentPin, Amount); _dispatcherAccessor.Dispatcher.Invoke(() => { if (!string.IsNullOrEmpty(errorMessage)) { ErrorMessage = errorMessage; Amount = 0; } else { // This is just to notify user of the application. Normally we should not show any message boxes, // because hardware is reponsible for getting cache. MessageBox.Show($"You have withdrown {Amount}. Now you will be redirected on the PIN screen."); ErrorMessage = null; Amount = 0; GlobalCommands.FinishCommand.Execute(null); } }); }