Ejemplo n.º 1
0
        public async Task <IActionResult> CreateIssue(NewIssueDto newIssueDto)
        {
            var user = await _userService.GetByIdAsync(newIssueDto.AssignedUserId);

            if (user == null)
            {
                return(BadRequest("Assigned user not found"));
            }

            var issue = _mapper.Map <Issue>(newIssueDto);

            issue.Status   = Status.New;
            issue.Assigned = user;
            // TODO: getting of current user
            issue.Reporter = new User
            {
                Id = (int)FakeUserId.TomasLight,
            };

            await _issueService.AddAsync(issue);

            var dto = _mapper.Map <IssueDto>(issue);

            return(Ok(dto));
        }