Exemplo n.º 1
0
        public IAccount findAccount(int id)
        {
            AAccount comp = new AAccount();

            comp.AssignID(id);
            if (Accounts.Contains(comp))
            {
                int index = Accounts.ToList().IndexOf(comp);
                return(Accounts.ElementAt(index));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public int CreateExpenseInline(string title, string description, double fee, int acct, ExpenseRepetition repetition = ExpenseRepetition.None, RepetitionPosition position = null)
        {
            if (findAccount(acct) == null)
            {
                AAccount account = new AAccount();
                account.AssignID(acct);
                if (!AddAccount(account))
                {
                    throw new InvalidOperationException("Account didn't exist and creation of new account failed!");
                }
            }

            AExpense exp = new AExpense(fee, findAccount(acct), repetition, position);

            AddExpense(exp);
            return(exp.ID);
        }
Exemplo n.º 3
0
        public int CreateExpenseInline(string title, string description, double fee, IEnumerable <int> accts, ExpenseRepetition repetition = ExpenseRepetition.None, RepetitionPosition position = null)
        {
            List <IAccount> accounts = new List <IAccount>(accts.Count());

            foreach (int acct in accts)
            {
                if (findAccount(acct) == null)
                {
                    AAccount account = new AAccount();
                    account.AssignID(acct);
                    if (!AddAccount(account))
                    {
                        throw new InvalidOperationException("Account didn't exist and creation of new account failed!");
                    }
                }

                accounts.Add(findAccount(acct));
            }

            AExpense exp = new AExpense(fee, accounts, repetition, position);

            AddExpense(exp);
            return(exp.ID);
        }