private async void OpenContextMenu(PaymentViewModel payment) { var result = await modifyDialogService.ShowEditSelectionDialog(); switch (result) { case ModifyOperation.Edit: EditPaymentCommand.Execute(payment); break; case ModifyOperation.Delete: DeletePaymentCommand.Execute(payment); break; } }
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(); }
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(); }
/// <summary> /// Init the view for a new PaymentViewModel. Is executed after the constructor call. /// </summary> /// <param name="type">Type of the PaymentViewModel. Is ignored when paymentId is passed.</param> /// <param name="paymentId">The id of the PaymentViewModel to edit.</param> public void Init(PaymentType type, int paymentId = 0) { TargetAccounts = new ObservableCollection <AccountViewModel>(accountRepository.GetList()); ChargedAccounts = new ObservableCollection <AccountViewModel>(TargetAccounts); if (paymentId == 0) { IsEdit = false; IsEndless = true; amount = 0; PrepareDefault(type); } else { IsEdit = true; PaymentId = paymentId; selectedPayment = paymentRepository.FindById(PaymentId); PrepareEdit(); } AccountViewModelBeforeEdit = SelectedPayment.ChargedAccount; }
private void EditPayment(PaymentViewModel payment) { ShowViewModel <ModifyPaymentViewModel>(new { paymentId = payment.Id }); }