private Dictionary <AccountCategory, Dictionary <AccountSubCategory, IEnumerable <AccountLiteViewModel> > > BuildChartOfAccounts(IEnumerable <Account> accounts)
        {
            var results = InitializeChartOfAccounts(true);
            Dictionary <AccountSubCategory, IEnumerable <AccountLiteViewModel> > categoryEntry = null;

            foreach (var account in accounts)
            {
                var accountSubCategory = (AccountSubCategory)account.AccountTypeId;
                var accountViewModel   = AccountLiteViewModel.FromAccount(account);

                switch (accountSubCategory)
                {
                case AccountSubCategory.Assets:
                case AccountSubCategory.Liabilities:
                case AccountSubCategory.OwnersEquity:
                    categoryEntry = results[AccountCategory.BalanceSheet];
                    break;

                case AccountSubCategory.Revenue:
                case AccountSubCategory.Expenses:
                    categoryEntry = results[AccountCategory.ProfitAndLoss];
                    break;
                }

                var subCategoryAccountList = categoryEntry[accountSubCategory] as List <AccountLiteViewModel>;
                subCategoryAccountList.Add(accountViewModel);
            }

            return(results);
        }
        public CategorizedAccountsViewModel(IEnumerable <Account> accounts)
        {
            if (accounts.IsEmpty())
            {
                AccountCategories = new Dictionary <AccountSubCategory, IEnumerable <AccountLiteViewModel> >();
            }
            else
            {
                AccountCategories = Enum
                                    .GetValues(typeof(AccountSubCategory))
                                    .Cast <AccountSubCategory>()
                                    .ToDictionary(
                    category => category,
                    category => new List <AccountLiteViewModel>() as IEnumerable <AccountLiteViewModel>);

                foreach (var account in accounts)
                {
                    var accountSubCategory     = (AccountSubCategory)account.AccountTypeId;
                    var accountViewModel       = AccountLiteViewModel.FromAccount(account);
                    var subCategoryAccountList = AccountCategories[accountSubCategory] as List <AccountLiteViewModel>;
                    subCategoryAccountList.Add(accountViewModel);
                }
            }
        }