private async Task Save() { try { using (WorkingScope.Enter()) { userSettings.NotifyByEmailOnPaymentSuccessful = PaymentSuccessfulViaEmail.Value; userSettings.NotifyBySMSOnPaymentSuccessful = PaymentSuccessfulViaSMS.Value; userSettings.NotifyByEmailOnPaymentFailed = PaymentFailedViaEmail.Value; userSettings.NotifyBySMSOnPaymentFailed = PaymentFailedViaSMS.Value; userSettings.NotifyByEmailOnIncomingTransfer = IncomingTransferViaEmail.Value; userSettings.NotifyBySMSOnIncomingTransfer = IncomingTransferViaSMS.Value; userSettings.NotifyByEmailOnOutgoingTransfer = OutgoingTransferViaEmail.Value; userSettings.NotifyBySMSOnOutgoingTransfer = OutgoingTransferViaSMS.Value; await userData.SaveSettings(userSettings); } } catch (Exception ex) { Crashes.TrackError(ex, new Dictionary <string, string> { { "page", "settings" }, { "operation", $"saving changes" } }); await View.DisplayAlert("Error", "An error occurred while saving settings" + ex, "Ok"); } }
public async Task Confirm() { try { if (!connectivity.IsConnected) { await View.DisplayAlert("Internet required", "To sign up the app requires internet connection.", "Ok"); return; } ConfirmSignUpResponse response; using (WorkingScope.Enter()) { (string deviceId, string deviceName) = GetDeviceInfo(); var request = new ConfirmSignUpRequest { RequestId = requestId, DeviceId = deviceId, DeviceName = deviceName, ConfirmationCode = ConfirmationCode.Value, }; response = await accountService.ConfirmSignup(request); } if (response.Success) { await dataFlow.UpdateUserId(response.UserId); await dataFlow.UpdateAccessCode(response.AccessCode); var setPinViewModel = createSetPinViewModel(); viewService.SetCurrentPage(setPinViewModel); } else { await View.DisplayAlert("Invalid Code", response.Error, "Ok"); } } catch (Exception ex) { Crashes.TrackError(ex, new Dictionary <string, string> { { "page", "confirmation code entry" }, { "operation", nameof(Confirm) } }); await View.DisplayAlert("Error", ex.Message, "Ok"); } }
public async Task Confirm() { try { if (!CanConfirm()) { return; } if (IsBusy) { return; } using (WorkingScope.Enter()) { ReadAddressFromView(currentAddress); await SaveAddress(secureStorage.GetUserId().Value, existingAddress, currentAddress); if (!existingAddress) { currentAddresses = currentAddresses.Union(new[] { currentAddress }).ToArray(); } await userData.SaveUserAddresses((currentAddresses).ToArray()); existingAddress = false; } if (onConfirmAction != null) { await onConfirmAction(View); } else { await navigationService.Pop(); } } catch (Exception ex) { Crashes.TrackError(ex, new Dictionary <string, string> { { "page", "edit address" }, { "operation", $"saving changes" } }); await View.DisplayErrorAlert("An error occurred. Please try again." + ex.Message); } }
public async Task Send() { try { if (!CanSend()) { return; } if (!connectivity.IsConnected) { await View.DisplayAlert("...", "Internet connection required", "Ok"); return; } var amount = decimal.Parse(Amount.Value); var request = new ChargeCardRequest { Amount = amount, }; using (WorkingScope.Enter()) { var response = await cardsService.ChargeCard(secureStorage.GetUserId().Value, appData.Cards.First().Id, request); appData.Cards.First().Balance = response.NewCardBalance; appData.BucketAmount = response.NewBucketAmount; await cardData.SaveCards(appData.Cards); await bucketData.SaveBucketInfo(new BucketInfo { Amount = appData.BucketAmount }); } await View.DisplayAlert("Done", "Card charged successfully!", "Ok"); } catch (Exception ex) { Crashes.TrackError(ex, new Dictionary <string, string> { { "page", "send bucket to card" }, { "operation", $"{nameof(BucketHomeViewModel)}.{nameof(Send)}" } }); await View.DisplayAlert("Error", "An error occurred while processing your request" + ex, "Ok"); } }
public async Task Confirm() { try { if (!connectivity.IsConnected) { await View.DisplayAlert("...", "Internet connection required", "Ok"); return; } Contracts.Models.Cards.OrderCardResponse result; using (WorkingScope.Enter()) { result = await cardOrderService.CreateOrder(new Contracts.Models.Cards.OrderCardRequest { UserId = secureStorage.GetUserId().Value }); } if (result.Success == true) { appData.Cards = appData.Cards.Union(new[] { new Card { State = CardState.Ordered, Id = -1, Name = "Order Pending" } }).ToArray(); await cardData.SaveCards(appData.Cards); await navigationService.Pop(); } } catch (Exception ex) { Crashes.TrackError(ex, new Dictionary <string, string> { { "page", "home page" }, { "operation", $"{nameof(OrderNewCardViewModel)}.{nameof(Confirm)}" } }); await View.DisplayAlert("Error", "An error occurred while processing your request" + ex, "Ok"); } }
public async Task SignUp() { if (!CanSignUp()) { await View.DisplayAlert("Invalid values", "Please enter all required values.", "Ok"); return; } try { if (!connectivity.IsConnected) { await View.DisplayAlert("Internet required", "To sign up the app requires internet connection.", "Ok"); return; } var requestObj = new SignUpRequest { BusinessName = BusinessName.Value, FirstName = FirstName.Value, LastName = LastName.Value, CountryCode = Country.Value?.DialingCode ?? GetCountryCode(), DeviceId = GetDeviceId(), EmailAddress = EmailAddress.Value, MobileNumber = MobileNumber.Value?.Replace(" ", "").Replace("-", ""), RequestForNewCode = false }; SignUpResponseModel result; using (WorkingScope.Enter()) { result = await accountService.SignUp(requestObj); } if (result != null) { if (result.StatusCode == 0) { using (WorkingScope.Enter()) { await dataFlow.InitializeUser(requestObj.BusinessName, requestObj.FirstName, requestObj.LastName, requestObj.CountryCode, requestObj.EmailAddress, requestObj.MobileNumber); } var confirmationPage = createConfirmationCodeEntryViewModel(result.RequestId); viewService.SetCurrentPage(confirmationPage); } else { var message = result.Error ?? "Unknown error."; await View.DisplayAlert("Error", message, "Ok"); } } else { var message = "There is an issue with communicating to our servers. Please try again."; await View.DisplayAlert("Error", message, "Ok"); } } catch (Exception ex) { Crashes.TrackError(ex, new Dictionary <string, string> { { "page", "sign up" }, { "operation", nameof(SignUp) } }); await View.DisplayAlert("Error", "An error occurred while processing your request" + ex, "Ok"); } }