private async void Save() { if (SelectedPayment.ChargedAccount == null) { ShowAccountRequiredMessage(); return; } if (SelectedPayment.IsRecurring && !IsEndless && EndDate.Date <= DateTime.Today) { ShowInvalidEndDateMessage(); return; } // Make sure that the old amount is removed to not count the amount twice. RemoveOldAmount(); if (amount < 0) { amount *= -1; } SelectedPayment.Amount = amount; //Create a recurring PaymentViewModel based on the PaymentViewModel or update an existing await PrepareRecurringPayment(); // Save item or update the PaymentViewModel and add the amount to the AccountViewModel await paymentService.SavePayment(SelectedPayment.Payment); settingsManager.LastDatabaseUpdate = DateTime.Now; #pragma warning disable 4014 backupManager.EnqueueBackupTask(); #pragma warning restore 4014 Close(this); }
private async void SaveCategory() { if (string.IsNullOrEmpty(SelectedCategory.Name)) { await dialogService.ShowMessage(Strings.MandatoryFieldEmptyTitle, Strings.NameRequiredMessage); return; } if (!IsEdit && await categoryService.CheckIfNameAlreadyTaken(SelectedCategory.Name)) { await dialogService.ShowMessage(Strings.ErrorMessageSave, Strings.DuplicateCategoryMessage); return; } await categoryService.SaveCategory(SelectedCategory.Category); settingsManager.LastDatabaseUpdate = DateTime.Now; #pragma warning disable 4014 backupManager.EnqueueBackupTask(); #pragma warning restore 4014 Close(this); }
private async void SaveAccount() { if (string.IsNullOrEmpty(SelectedAccount.Name)) { await dialogService.ShowMessage(Strings.MandatoryFieldEmptyTitle, Strings.NameRequiredMessage); return; } SelectedAccount.CurrentBalance = amount; if (!IsEdit && accountRepository.GetList( a => string.Equals(a.Name, SelectedAccount.Name, StringComparison.CurrentCultureIgnoreCase)).Any()) { await dialogService.ShowMessage(Strings.ErrorMessageSave, Strings.DuplicateAccountMessage); return; } if (accountRepository.Save(SelectedAccount)) { settingsManager.LastDatabaseUpdate = DateTime.Now; #pragma warning disable 4014 backupManager.EnqueueBackupTask(); #pragma warning restore 4014 Close(this); } }
public async Task <OperationResult> EnqueueBackupTask(int attempts = 0) { if (!settingsFacade.IsBackupAutouploadEnabled) { return(OperationResult.Succeeded()); } if (!settingsFacade.IsLoggedInToBackupService) { var loginResult = await Login().ConfigureAwait(true); if (!loginResult.Success) { return(loginResult); } } var result = await backupManager.EnqueueBackupTask() .ConfigureAwait(true); if (result.Success) { settingsFacade.LastDatabaseUpdate = DateTime.Now; } return(result); }
public async Task EnqueueBackupTask(int attempts = 0) { if (!settingsFacade.IsLoggedInToBackupService) { await Login(); } await backupManager.EnqueueBackupTask(); settingsFacade.LastDatabaseUpdate = DateTime.Now; }
private async void DeletePayment(PaymentViewModel payment) { if (!await dialogService .ShowConfirmMessage(Strings.DeleteTitle, Strings.DeletePaymentConfirmationMessage)) { return; } await paymentService.DeletePayment(payment.Payment); settingsManager.LastDatabaseUpdate = DateTime.Now; #pragma warning disable 4014 backupManager.EnqueueBackupTask(); #pragma warning restore 4014 LoadCommand.Execute(); }
/// <summary> /// Creates a new backup from OneDrive when the last modification is newer then the last OneDrive backup. /// </summary> public async void UploadBackupIfNewwer() { try { if (!SettingsHelper.IsBackupAutouploadEnabled) { return; } globalBusyIndicatorState.IsActive = true; if (await backupManager.GetBackupDate() < SettingsHelper.LastDatabaseUpdate) { await backupManager.EnqueueBackupTask(0); } } catch (OneDriveException ex) { Mvx.Trace(MvxTraceLevel.Error, ex.Message); } globalBusyIndicatorState.IsActive = false; }
private async void DeletePayment(PaymentViewModel payment) { if (!await dialogService .ShowConfirmMessage(Strings.DeleteTitle, Strings.DeletePaymentConfirmationMessage)) { return; } var deletePaymentSucceded = await paymentManager.DeletePayment(payment); var removePaymentAmountSuceed = paymentManager.RemovePaymentAmount(payment); if (deletePaymentSucceded && removePaymentAmountSuceed) { settingsManager.LastDatabaseUpdate = DateTime.Now; #pragma warning disable 4014 backupManager.EnqueueBackupTask(); #pragma warning restore 4014 } LoadCommand.Execute(); }
public async Task <OperationResult> EnqueueBackupTask(int attempts = 0) { if (!settingsFacade.IsLoggedInToBackupService) { var loginResult = await Login(); if (!loginResult.Success) { return(loginResult); } } var result = await backupManager.EnqueueBackupTask(); if (result.Success) { settingsFacade.LastDatabaseUpdate = DateTime.Now; } return(result); }