Exemplo n.º 1
0
        public bool SetTransaction(BO.Transaction transaction)
        {
            bool insert = (transaction.Id <= 0);
            bool result = false;

            using (KapitalDataContext context = new KapitalDataContext(ConnectionString))
            {
                RepositoryAdapter<BO.Transaction, Transaction, TransactionCopyExtensions> adapter =
                    new RepositoryAdapter<BO.Transaction, Transaction, TransactionCopyExtensions>(this);

                if (insert)
                {
                    result = adapter.Insert(transaction, context.Transactions, context);
                }
                else
                {
                    result = adapter.Update(transaction, context.Transactions.Where(t => t.TransactionId == transaction.Id), context);
                }
            }

            return result;
        }
Exemplo n.º 2
0
        public bool SetAccount(BO.Account account)
        {
            bool insert = (account.Id <= 0);
            bool result = false;

            using (KapitalDataContext context = new KapitalDataContext(ConnectionString))
            {
                RepositoryAdapter<BO.Account, Account, AccountCopyExtensions> adapter =
                    new RepositoryAdapter<BO.Account, Account, AccountCopyExtensions>(this);

                if (insert)
                {
                    result = adapter.Insert(account, context.Accounts, context);
                }
                else
                {
                    result = adapter.Update(account, context.Accounts.Where(x => x.AccountId == account.Id), context);
                }
            }

            return result;
        }