public ConfirmationResponse Execute(EditWorkTaskRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var entity  = _workTaskRepository.Read(request.Id);
            var backlog = _projectRepository.ReadProductBacklog(entity.ProjectId);

            var oldChildren = entity.ChildTasks;

            UpdateWorkTask(entity, request);

            var hasBacklogChanged = false;

            if (entity.Type == WorkTaskType.UserStory)
            {
                var removedChildren = oldChildren.Except(entity.ChildTasks).ToArray();
                foreach (var task in entity.ChildTasks)
                {
                    hasBacklogChanged |= backlog.RemoveTaskFromBacklog(task);
                }

                foreach (var child in removedChildren)
                {
                    backlog.AddTaskToBacklog(new ProductBacklog.WorkTaskWithStatus(child, ProductBacklog.WorkTaskStatus.ToDo));
                }

                hasBacklogChanged |= removedChildren.Any();
            }
            else if (entity.Type != WorkTaskType.Epic && entity.ParentTask.IsBlankIdentity())
            {
                backlog.AddTaskToBacklog(new ProductBacklog.WorkTaskWithStatus(entity.Id, ProductBacklog.WorkTaskStatus.ToDo));
                hasBacklogChanged = true;
            }

            _workTaskRepository.Update(entity);
            if (hasBacklogChanged)
            {
                _projectRepository.UpdateProductBacklog(backlog);
            }

            return(new ConfirmationResponse("Work task updated successfully.")
            {
                Id = entity.Id,
            });
        }