public async Task <ITravelExpense> InsertAsync(ITravelExpense entity)
        {
            entity.CheckArgument(nameof(entity));
            entity.Travel.CheckArgument(nameof(entity.Travel));
            entity.Expenses.CheckArgument(nameof(entity.Expenses));

            var result = new TravelExpense();

            result.TravelEntity.CopyProperties(entity.Travel);
            foreach (var item in entity.Expenses)
            {
                var expense = new Expense();

                expense.Travel = result.TravelEntity;
                expense.CopyProperties(item);
                await expenseController.InsertAsync(expense);

                result.ExpenseEntities.Add(expense);
            }
            return(result);
        }
        public async Task <ITravelExpense> UpdateAsync(ITravelExpense entity)
        {
            entity.CheckArgument(nameof(entity));
            entity.Travel.CheckArgument(nameof(entity.Travel));
            entity.Expenses.CheckArgument(nameof(entity.Expenses));

            //Delete all costs that are no longer included in the list.
            foreach (var item in await expenseController.QueryAsync(e => e.TravelId == entity.Travel.Id))
            {
                var tmpExpense = entity.Expenses.SingleOrDefault(i => i.Id == item.Id);

                if (tmpExpense == null)
                {
                    await expenseController.DeleteAsync(item.Id);
                }
            }

            var result = new TravelExpense();
            var travel = await travelController.UpdateAsync(entity.Travel);

            result.TravelEntity.CopyProperties(travel);
            foreach (var item in entity.Expenses)
            {
                if (item.Id == 0)
                {
                    item.TravelId = entity.Travel.Id;
                    var insEntity = await expenseController.InsertAsync(item);

                    item.CopyProperties(insEntity);
                }
                else
                {
                    var updEntity = await expenseController.UpdateAsync(item);

                    item.CopyProperties(updEntity);
                }
            }
            return(result);
        }