示例#1
0
        protected override void CommitOperation(ExpensesContext db, Repayment operation, bool rollback)
        {
            var da = (from d in db.Debts
                      join a in db.Accounts on d.AccountId equals a.Id
                      where d.Id == operation.DebtId
                      select new { debt = d, account = a }).First();

            OperationsService.CommitAndRound(operation, da.account, da.debt.Type == DebtType.Lend ? OperationType.Income : OperationType.Expense, rollback);
            var debtWrapper = new AmountWrapper(() => da.debt.RepayedAmount, amount => da.debt.RepayedAmount = amount);

            OperationsService.CommitAndRound(operation, debtWrapper, OperationType.Income, rollback);
        }
示例#2
0
        protected override void CommitOperation(ExpensesContext db, Debt operation, bool rollback)
        {
            var wrapper = new AmountWrapper(() => operation.Amount - operation.RepayedAmount, amount => operation.Amount = amount + operation.RepayedAmount);

            OperationsService.CommitAndRound(wrapper, db.Accounts.Find(operation.AccountId), operation.Type == DebtType.Borrow ? OperationType.Income : OperationType.Expense, rollback);
        }