public async Task <AggregateIssue> Create(ICreateAggregateIssue command) { await CheckIfProjectExist(command.ProjectId); await authorizationService.CheckUserMembership(callContext.UserId, command.ProjectId); AggregateIssue issue; switch (command) { case CreateTask createTask: issue = new Model.Task( 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 ); break; case CreateNfr createNfr: issue = new Model.Nfr( 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 ); break; case CreateBug createBug: issue = new Model.Bug( 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 ); break; default: throw new InvalidCastException("Cannot cast command to Create Aggregate Issue command"); } issue.Created(); 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 Model.ChildBug BugToChildBug(Model.Bug bug) { return(new Model.ChildBug(bug.Id, bug.ProjectId, bug.Title, bug.Description, bug.Status, bug.ReporterId, bug.AssigneeId, bug.CreatedAt, bug.UpdatedAt, bug.Labels, bug.Comments)); }