public async Task <IActionResult> Assign([FromRoute] string id, [FromBody] IssueAssignDto dto) { // check if user has permission var userId = User.GetUserId(); var project = await _repo.GetProject(dto.ProjectId, userId); if (project == null) { return(Unauthorized(new { message = "You do not have the auhorization to assign the issue." })); } var issue = await _repo.GetIssue(id); issue.IssuedTo.Add(new IssueUser { IsStarred = false, IssueId = id, UserId = dto.User.Id, }); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest(new { message = "Error assigning the issue." })); }
public async Task AssignToAsync(IssueAssignDto input) { var issue = await _issueRepository.GetAsync(input.IssueId); var user = await _userRepository.GetAsync(input.UserId); await _issueManager.AssignToAsync(issue, user); await _issueRepository.UpdateAsync(issue); }