public async Task CreateIssue(Guid issueId, string title, string description, DateTime?startDate, DateTime?dueDate, Guid projectId, Guid trackerId, Guid statusId, Guid priorityId, Guid authorId, Guid?assigneeId, CancellationToken cancellationToken) { var project = await _projectRepository.Get(projectId, cancellationToken); if (project == null) { throw new ProjectNotFoundException(); } var tracker = await _trackerRepository.Get(trackerId, cancellationToken); if (tracker == null) { throw new TrackerNotFoundException(); } var issueStatus = await _issueStatusRepository.Get(statusId, cancellationToken); if (issueStatus == null) { throw new IssueStatusNotFoundException(); } var issuePriority = await _issuePriorityRepository.Get(priorityId, cancellationToken); if (issuePriority == null) { throw new IssuePriorityNotFoundException(); } if (assigneeId != null) { var assignee = await _userRepository.Get(assigneeId.Value, cancellationToken); if (assignee == null) { throw new AssigneeNotFoundException(); } } var issue = await _issueRepository.Get(issueId, cancellationToken); if (issue != null) { throw new IssueAlreadyExistsException(); } issue = new Issue(issueId, title, description, startDate, dueDate, trackerId, statusId, priorityId, authorId, assigneeId); project.AddIssue(issue); await _projectRepository.Save(project); }
public async Task <IActionResult> Create( CancellationToken cancellationToken, [FromBody] CreateIssueStatusBinding binding, [FromServices] IIssueStatusRepository issueStatusRepository) { var issueStatus = await issueStatusRepository.Get(binding.Id, cancellationToken); if (issueStatus != null) { if (!issueStatus.Name.Equals(binding.Name)) { throw new ApiException(HttpStatusCode.Conflict, ErrorCode.IssueStatusAlreadyExists, "Issue status already exists with other parameters"); } } issueStatus = new IssueStatus(binding.Id, binding.Name, binding.IsActive); await issueStatusRepository.Save(issueStatus); return(CreatedAtRoute("GetIssueStatusAdminRoute", new { id = issueStatus.Id }, null)); }