private void Save_Button_Click(object sender, RoutedEventArgs e) { try { if (vm.IsAddMode) { // Store Initial Deposit info or will be lost on account save decimal?amount = vm.Account.InitialBalance; // Save Account without transaction to get an AccountId vm.OGAccount = accountsOM.SaveAccount(vm.Account); // Create Initial Transaction and update the account with it's info if (amount.HasValue) { InitialDeposit = new TransactionSaveInfo() { Amount = amount.Value, DateTime_Occurred = vm.Account.DateTime_Created, FromAccount = vm.SelectedFromAccount, IsConfirmed = true, IsUserCreated = false, Title = "Initial Deposit", OccerrenceAccount = null, ToAccount = vm.Account.AccountId, TransactionType = TransactionType.Deposit, Notes = $"Initial Deposit for {vm.Account.AccountName} {Constants.Accounts.GetDisplay(vm.Account.AccountType)}" }; TransactionDetailBase savedTransaction = transactionsOM.SaveTransaction(InitialDeposit); vm.Account.InitialBalance = savedTransaction.Amount; vm.Account.InitialDepositAccountId = savedTransaction.FromAccount.AccountId; vm.Account.InitialDepositId = savedTransaction.TransactionId; vm.OGAccount = accountsOM.SaveAccount(vm.Account); } } else { if (vm.IsDirty) { vm.OGAccount = accountsOM.SaveAccount(vm.Account); } } this.Close(); } catch (Exception ex) { //todo: add error logging } }
private void Save_Button_Click(object sender, RoutedEventArgs e) { try { if (IsAddMode) { var amount = Account.InitialBalance.HasValue ? Account.InitialBalance.Value : 0.0M; InitialDeposit = new TransactionSaveInfo() { Amount = amount, DateTime_Occurred = Account.DateTime_Created, FromAccount = vm.SelectedFromAccount, IsConfirmed = true, IsUserCreated = false, Title = "Default Cash Account Initial Deposit", OccerrenceAccount = null, ToAccount = Account.AccountId, TransactionType = TransactionType.Deposit }; if (InitialDeposit.Amount != 0) { transactionsOM.SaveTransaction(InitialDeposit); } } else { if (Account != OGAccount) { OGAccount = accountsOM.SaveAccount(Account); } } this.Close(); } catch (Exception ex) { //todo: add error logging } }
private void Save_Button_Click(object sender, RoutedEventArgs e) { transactionsOM.SaveTransaction(vm.ExportSaveModel()); this.Close(); }