Ejemplo n.º 1
0
        public PaymentsAccountModel(Customer customer)
        {
            PayPointCards.AddRange(customer.PayPointCards.Select(PayPointCardModel.FromCard));

            CurrentBankAccount = BankAccountModel.FromCard(customer.CurrentCard);

            int currentBankAccountId = 0;

            if (CurrentBankAccount != null)
            {
                currentBankAccountId = CurrentBankAccount.Id;
            }

            BankAccounts.AddRange(customer.BankAccounts.Where(a => a.Id != currentBankAccountId).Select(BankAccountModel.FromCard));

            CustomerDefaultCardSelectionAllowed = customer.DefaultCardSelectionAllowed;
        }
Ejemplo n.º 2
0
        public MainDashboardViewModel()
        {
            if (CurrentUserHouseholdId != 0)
            {
                Household = _db.Households.AsNoTracking().FirstOrDefault(h => h.Id == CurrentUserHouseholdId);

                BankAccounts.AddRange(_db.BankAccounts.AsNoTracking().Where(b => b.HouseholdId == CurrentUserHouseholdId).ToList());
                Budgets.AddRange(_db.Budgets.AsNoTracking().Where(b => b.HouseholdId == CurrentUserHouseholdId).ToList());

                BudgetItems.AddRange(Budgets.SelectMany(b => b.BudgetItems));

                var transactions = _db.Transactions.AsNoTracking();
                foreach (var transaction in transactions)
                {
                    if (BankAccounts.Any(ba => ba.Id == transaction.BankAccountId))
                    {
                        Transactions.Add(transaction);
                    }
                }
            }
        }