public async Task <Model.Subtask> GenerateSubtask(AddSubtaskToTask command) { await authorizationService.CheckUserMembership(callContext.UserId, command.ProjectId); var issue = new Model.Subtask( id: Guid.NewGuid(), projectId: command.ProjectId, title: command.Title, description: command.Description, status: IssueStatus.Todo, reporterId: callContext.UserId, assigneeId: null, createdAt: DateTime.UtcNow, updatedAt: DateTime.UtcNow ); if (command.LabelsIds != null) { var labels = await labelsSearcher.GetLabels(command.ProjectId); issue.AssignLabels(command.LabelsIds, labels); } if (command.AssigneeId != null) { var assignee = await userRepository.GetAsync(command.AssigneeId.Value); await issue.AssignAssignee(assignee, authorizationService); } command.CreatedId = issue.Id; return(issue); }
public async Task HandleAsync(AddSubtaskToTask command) { var task = await taskRepository.GetAsync(command.TaskId); var originalVersion = task.Version; task.AddSubtask(taskFactory, command); var Subtask = task.Subtasks.OrderBy(x => x.CreatedAt).Last(); await taskRepository.UpdateChildEntity(task, originalVersion, Subtask); }
public void AddSubtask(IIssueFactory issueFactory, AddSubtaskToTask command) { if (Status == IssueStatus.Done) { throw new CannotAddChildIssueWhenParentIssueIsDone <Task, Subtask>(Id); } var subtask = System.Threading.Tasks.Task.Run(() => issueFactory.GenerateSubtask(command)).GetAwaiter().GetResult(); Subtasks.Add(subtask); Update(new SubtaskAddedToTask(subtask.Id, Id, ProjectId, subtask.Title, subtask.Description, subtask.ReporterId, subtask.AssigneeId, subtask.Labels.Select(x => x.Id).ToList(), subtask.CreatedAt)); }
public async Task <IActionResult> AddToTask([FromRoute] Guid projectId, [FromRoute] Guid taskId, [FromBody] AddSubtaskToTask command) { command.ProjectId = projectId; command.TaskId = taskId; await commandQueryBus.SendAsync(command); return(Created("", command.CreatedId)); }