예제 #1
0
        public List<BO.Account> GetAccountsByBank(int bankId)
        {
            List<BO.Account> accounts = null;

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

                accounts = adapter.GetAllByParentID(context.Accounts.Where(a => a.BankId == bankId));
            }

            return accounts;
        }
예제 #2
0
        public bool DeleteBank(int id)
        {
            bool result = false;

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

                result = adapter.Delete(context.Banks.Where(x => x.BankId == id), context);
            }

            return result;
        }
예제 #3
0
        public bool DeleteTransaction(int transactionId)
        {
            bool result = false;

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

                result = adapter.Delete(context.Transactions.Where(x => x.TransactionId == transactionId), context);

                Transaction item = (from x in context.Transactions
                                    where x.TransactionId == transactionId
                                    select x).SingleOrDefault();

                context.Transactions.DeleteOnSubmit(item);

                context.SubmitChanges();
            }

            return result;
        }
예제 #4
0
        public List<BO.Bank> GetAllBanks()
        {
            List<BO.Bank> banks = null;

            using (KapitalDataContext context = new KapitalDataContext(ConnectionString))
            {
                RepositoryAdapter<BO.Bank, Bank, BankCopyExtensions> adapter =
                    new RepositoryAdapter<BO.Bank, Bank, BankCopyExtensions>(this);
                banks = adapter.GetAll(context.Banks);
            }

            return banks;
        }
예제 #5
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;
        }
예제 #6
0
        public bool SetBank(BO.Bank bank)
        {
            bool insert = (bank.ID <= 0);
            bool result = false;

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

                if (insert)
                {
                    result = adapter.Insert(bank, context.Banks, context);
                }
                else
                {
                    throw new NotImplementedException();
                }

            }

            return result;
        }
예제 #7
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;
        }
예제 #8
0
        public List<BO.User> GetUsers()
        {
            List<BO.User> users = null;

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

                users = adapter.GetAll(context.Users);
            }

            return users;
        }
예제 #9
0
        public BO.User GetUser(string username)
        {
            BO.User user = null;

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

                user = adapter.Get(context.Users.Where(u => String.Compare(u.Username, username, true) == 0));
            }

            return user;
        }
예제 #10
0
        public BO.User GetUser(int id)
        {
            BO.User user = null;

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

                user = adapter.Get(context.Users.Where(u => u.UserId == id));
            }

            return user;
        }
예제 #11
0
        public List<Models.Transaction> GetTransactionsWithinRange(Guid accountId, DateTime start, DateTime end, TagType type)
        {
            List<BO.Transaction> transactions = null;

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

                var query = context.Transactions.Where(t => t.AccountId == accountId);

                query = query.Where(t => t.Date >= start && t.Date <= end);

                transactions = adapter.GetAllByParentID(query);
            }

            return transactions;
        }
예제 #12
0
        public List<Models.Transaction> GetTransactionsByAccount(Guid accountId, string sort)
        {
            List<BO.Transaction> transactions = null;

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

                var query = context.Transactions.Where(t => t.AccountId == accountId);

                if (String.Compare(sort, "date-desc", true) == 0)
                {
                    query = query.OrderByDescending(t => t.Date);
                }
                else
                {
                    query = query.OrderBy(t => t.Date);
                }

                transactions = adapter.GetAllByParentID(query);
            }

            return transactions;
        }
예제 #13
0
        public List<Models.Transaction> GetTransactionsByAccount(Guid accountId)
        {
            List<BO.Transaction> transactions = null;

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

                transactions = adapter.GetAllByParentID(context.Transactions.Where(t => t.AccountId == accountId));
            }

            return transactions;
        }
예제 #14
0
        public BO.Transaction GetTransaction(int transactionId)
        {
            BO.Transaction transaction = null;

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

                transaction = adapter.Get(context.Transactions.Where(t => t.TransactionId == transactionId));
            }

            return transaction;
        }
예제 #15
0
        public BO.Bank GetBank(int id)
        {
            BO.Bank bank = null;

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

                bank = adapter.Get(context.Banks.Where(b => b.BankId == id));
            }

            return bank;
        }