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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }