public async Task <Account> GetAccountAsync(int id, int numEntries = 1000)
        {
            Account account;
            IEnumerable <dto.Tags>      tags           = new dto.Tags[0];
            IEnumerable <AccountLedger> accountLedgers = new AccountLedger[0];

            using (var transactionHelper = this._repositoryService.GetTransactionHelper())
            {
                var tagsRepository = this._repositoryService.GetTagsRepository(transactionHelper);
                tags = (await tagsRepository.GetTagsForAccountAsync(id)).ToList();
            }
            using (var transactionHelper = this._repositoryService.GetTransactionHelper())
            {
                var accountRepository = this._repositoryService.GetAccountRepository(transactionHelper);
                account = new Account(await accountRepository.GetAccountAsync(id));
            }
            if (numEntries > 0)
            {
                using (var transactionHelper = this._repositoryService.GetTransactionHelper())
                {
                    var accountLedgerRepository = this._repositoryService.GetAccountLedgerRepository(transactionHelper);
                    accountLedgers = (await accountLedgerRepository.GetLastNumEntriesAsync(id, numEntries)).Select(e => new AccountLedger(e, id)).ToList();
                }
            }
            account.Tags          = tags;
            account.LedgerEntries = accountLedgers;
            return(account);
        }
        public async Task <Account> GetAccountAsync(int id, DateTimeOffset startDate, DateTimeOffset endDate)
        {
            Account account;
            IEnumerable <dto.Tags>      tags           = new dto.Tags[0];
            IEnumerable <AccountLedger> accountLedgers = new AccountLedger[0];

            using (var transactionHelper = this._repositoryService.GetTransactionHelper())
            {
                var tagsRepository = this._repositoryService.GetTagsRepository(transactionHelper);
                tags = (await tagsRepository.GetTagsForAccountAsync(id)).ToList();
            }
            using (var transactionHelper = this._repositoryService.GetTransactionHelper())
            {
                var accountRepository = this._repositoryService.GetAccountRepository(transactionHelper);
                account = new model.Account(await accountRepository.GetAccountAsync(id));
            }
            using (var transactionHelper = this._repositoryService.GetTransactionHelper())
            {
                var accountLedgerRepository = this._repositoryService.GetAccountLedgerRepository(transactionHelper);
                accountLedgers = (await accountLedgerRepository.GetEntriesBetweenDatesAsync(id, startDate, endDate)).Select(e => new AccountLedger(e, id)).ToList();
            }
            account.Tags          = tags;
            account.LedgerEntries = accountLedgers;
            return(account);
        }
        public async Task <IEnumerable <Account> > GetAccountsAsync()
        {
            IEnumerable <dto.Tags> tags = new dto.Tags[0];

            using (var transactionHelper = this._repositoryService.GetTransactionHelper())
            {
                var tagsRepository = this._repositoryService.GetTagsRepository(transactionHelper);
                tags = (await tagsRepository.GetTagsAsync()).ToList();
            }
            using (var transactionHelper = this._repositoryService.GetTransactionHelper())
            {
                var accountRepository          = this._repositoryService.GetAccountRepository(transactionHelper);
                IEnumerable <Account> accounts = (await accountRepository.GetAccountsAsync()).Select(a => new Account(a)).ToList();
                foreach (var account in accounts)
                {
                    account.Tags = tags.Where(t => t.AccountId == account.Id).ToList();
                }
                return(accounts);
            }
        }