コード例 #1
0
        public void GivenTheFollowingTransaction(string category, string paymentMethod, Table data)
        {
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context));

            switch (_transactionType)
            {
                case TransactionTypes.Income:
                    _transaction = data.CreateInstance<Income>();
                    _transactionService = new IncomeService(new IncomeRepository(context));
                    _categoryService = new IncomeCategoryService(new IncomeCategoryRepository(context));
                    break;
                case TransactionTypes.Expense:
                    _transaction = data.CreateInstance<Expense>();
                    _transactionService = new ExpenseService(new ExpenseRepository(context));
                    _categoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(context));
                    break;
            }

            if (!string.IsNullOrWhiteSpace(paymentMethod))
            {
                _paymentMethod = new PaymentMethod(0, paymentMethod);
                _transaction.Method = _paymentMethod;
            }

            if (!string.IsNullOrWhiteSpace(category))
            {
                _category = new DataClasses.Category(0, category);
                _transaction.Category = _category;
            }

            if (_transaction.Date.Equals(default(DateTime)))
            {
                _transaction.Date = DateTime.Today;
            }
        }
コード例 #2
0
        public void GivenTheFollowingTransaction(string category, string paymentMethod, Table data)
        {
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context));
            switch (_transactionType)
            {
                case TransactionTypes.Income:
                    _transaction = data.CreateInstance<Income>();
                    _transactionService = new IncomeService(new IncomeRepository(context));
                    _categoryService = new IncomeCategoryService(new IncomeCategoryRepository(context));
                    break;
                case TransactionTypes.Expense:
                    _transaction = data.CreateInstance<Expense>();
                    _transactionService = new ExpenseService(new ExpenseRepository(context));
                    _categoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(context));
                    break;
            }

            _paymentMethod = _paymentMethodService.Create(paymentMethod);
            _transaction.Method = _paymentMethod;
            _transaction.PaymentMethodId = _paymentMethod.Id;

            _category = _categoryService.Create(category);
            _transaction.Category = _category;
            _transaction.CategoryId = _category.Id;
            _transaction.Date = DateTime.Today;

            _transaction.Id = 1;
            _transactionService.Create(_transaction);
        }
コード例 #3
0
 public void Setup()
 {
     context = new TestAccountingDataContext();
     _transaction = null;
     _transactionService = null;
     _categoryService = null;
     _paymentMethodService = null;
     _category = null;
     _paymentMethod = null;
 }
コード例 #4
0
 public static Income TryParseToIncome(Transaction t)
 {
     var i = t as Income;
     if (i == null)
     {
         throw new ArgumentException("The transaction is the wrong type");
     }
     i.Id = t.Id;
     i.Amount = t.Amount;
     i.Date = t.Date;
     i.Comments = t.Comments;
     i.Method = t.Method;
     i.PaymentMethodId = t.PaymentMethodId;
     i.CategoryId = t.CategoryId;
     if (t.Category != null)
     {
         i.Category = new IncomeCategory(t.Category.Id, t.Category.Name);
     }
     else
     {
         i.Category = null;
     }
     return i;
 }
コード例 #5
0
 public static Expense TryParseToExpense(Transaction t)
 {
     var e = t as Expense;
     if (e == null)
     {
         throw new ArgumentException("The transaction is the wrong type");
     }
     e.Id = t.Id;
     e.Amount = t.Amount;
     e.Date = t.Date;
     e.Comments = t.Comments;
     e.Method = t.Method;
     e.PaymentMethodId = t.PaymentMethodId;
     e.CategoryId = t.CategoryId;
     if (t.Category != null)
     {
         e.Category = new ExpenseCategory(t.Category.Id, t.Category.Name);
     }
     else
     {
         e.Category = null;
     }
     return e;
 }
コード例 #6
0
ファイル: IncomeService.cs プロジェクト: stoiandan/MyHome
 void ITransactionService.Create(Transaction transaction)
 {
     var income = TryParseToIncome(transaction);
     Create(income);
 }
コード例 #7
0
ファイル: IncomeService.cs プロジェクト: stoiandan/MyHome
 void ITransactionService.Save(Transaction transaction)
 {
     var income = TryParseToIncome(transaction);
     Save(income);
 }
コード例 #8
0
ファイル: ExpenseService.cs プロジェクト: stoiandan/MyHome
 void ITransactionService.Create(Transaction transaction)
 {
     var expense = TryParseToExpense(transaction);
     Create(expense);
 }
コード例 #9
0
ファイル: ExpenseService.cs プロジェクト: stoiandan/MyHome
 void ITransactionService.Save(Transaction transaction)
 {
     var expense = TryParseToExpense(transaction);
     Save(expense);
 }