private Core.Entities.WorkTask ToDomainEntity(CreateWorkTaskRequest request) { return(new Core.Entities.WorkTask( _workTaskRepository.GenerateNewIdentity(), request.ProjectId, request.Type, request.Name, request.StoryPoints, request.Description, request.ParentTask, request.ChildTasks, new Identity[0], request.Steps, request.Documents)); }
public ConfirmationResponse Execute(CreateWorkTaskRequest request) { request.ThrowExceptionIfInvalid(); var project = _projectRepository.Read(request.ProjectId); var entity = ToDomainEntity(request); var backlog = _projectRepository.ReadProductBacklog(project.Id); var shouldUpdateProductBacklog = true; if (entity.Type == WorkTaskType.Epic) { backlog.AddTaskToBacklog(new ProductBacklog.WorkTaskWithStatus(entity.Id, ProductBacklog.WorkTaskStatus.ToDo)); } else if (entity.Type == WorkTaskType.UserStory) { foreach (var task in entity.ChildTasks) { backlog.RemoveTaskFromBacklog(task); } backlog.AddTaskToBacklog(new ProductBacklog.WorkTaskWithStatus(entity.Id, ProductBacklog.WorkTaskStatus.ToDo)); } else if (entity.ParentTask.IsBlankIdentity()) { backlog.AddTaskToBacklog(new ProductBacklog.WorkTaskWithStatus(entity.Id, ProductBacklog.WorkTaskStatus.ToDo)); } else { shouldUpdateProductBacklog = false; } _workTaskRepository.Create(entity); if (shouldUpdateProductBacklog) { _projectRepository.UpdateProductBacklog(backlog); } return(new ConfirmationResponse("Work task created successfully.") { Id = entity.Id, }); }