protected static Expense mapUp(RootExpense data) { Expense expense; IEnumerable <Contribution> contributions; contributions = data.Contributions .map(mapUp); expense = data.Head .mapTo(e => new Expense(e.Id.Value, e.Date, e.Concept, contributions)); data.Debtors .map(mapUp) .ToList() .ForEach(expense.setDebtor); data.Tags .map(mapUp) .ToList() .ForEach(expense.setTag); return(expense); }
public void save(Expense expense) { RootExpense fullExpense; this.assert.isNotNull(expense); fullExpense = new RootExpense { Head = mapDown(expense), Tags = expense.Tags .map <TagData>() .ToList(), Debtors = expense.Debtors .map <UserData>() .ToList(), Contributions = expense.Contributions .Select(mapDown) .ToList(), }; this.expenses.set(fullExpense); }