public void Update() { if (!IsDirty) { return; } if (!IsValid()) { return; } var _taskRepository = new TaskRepository(); var dto = CreateDTOFromTask(this); TransactionUtil.DoTransactional(t => { if (IsDeleted) { foreach (Comment comment in Comments) { comment.MarkDeleted(); comment.Update(t); } _taskRepository.ExecuteDelete(dto.ID, t); } else { if (IsNew) { _taskRepository.ExecuteInsert(dto, t); } else { _taskRepository.ExecuteUpdate(dto, t); } } foreach (Comment comment in Comments) { comment.Update(t); } foreach (Comment comment in Comments.DeleteComments) { comment.Update(t); } Comments.DeleteComments.Clear(); }); }