public virtual void RemoveTimeEntry(int timeEntryId) { var timeEntry = TimeEntries.Single(te => te.Id == timeEntryId); if (timeEntry == null) { throw new EntityDeleteException("Timeentry not found in task: " + timeEntryId); } if (timeEntry.Invoice != null) { throw new EntityDeleteException("Timeentry cannot be deleted when billed: Id:" + timeEntry.Id); } TimeEntries.Remove(timeEntry); }