예제 #1
0
        internal TransactionModalVM GetTransactionModalVM(int?transactionId)
        {
            TransactionDetailBase transaction;

            if (transactionId.HasValue)
            {
                transaction = MapRepoTransactionToTransactionBase(Repo.GetTransactionById(transactionId.Value));
            }
            else
            {
                transaction = new TransactionDetailBase();
            }

            return(new TransactionModalVM(transaction,
                                          Transactions.TransactionTypesDropDown,
                                          Time.GetHoursComboBoxItems(),
                                          Time.GetMeridianComboBoxItems(),
                                          Time.GetTimeZonesComboBoxItems(),
                                          new List <IComboBoxItem>()
            {
                new GenericComboBoxItem("Not yet Implemented")
            },
                                          Repo.GetAccountComboBoxInfo(new List <string>(Enum.GetNames(typeof(AccountType)))).ConvertRepoToView(),
                                          transactionId.HasValue
                                          ));
        }
예제 #2
0
        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
            }
        }