public async Task UpdateAsync(Guid settlementId, Guid userId, Guid expenseId, string name, decimal cost) { var userExpenses = await _settlementRepository.GetExpensesOrFailAsync(settlementId, userId); var expense = userExpenses.SingleOrDefault(x => x.Id == expenseId); if (userExpenses == null) { throw new Exception($"Expense with id: '{expenseId}' does not exist."); } expense.SetName(name); expense.SetCost(cost); manager.Settle(await _settlementRepository.GetAsync(settlementId)); await _settlementRepository.UpdateExpenseAsync(settlementId, expense); }