public async Task <IActionResult> Update([FromRoute] string projectId, [FromRoute] string phaseId, [FromBody] PhaseUpdateDto dto)
        {
            var userId      = User.GetUserId();
            var projectUser = await _repo.GetProjectUser(projectId, userId);

            if (projectUser == null)
            {
                return(Unauthorized(new { message = "You do not have access to the project." }));
            }

            var phase = await _repo.GetPhase(phaseId);

            phase.Name = dto.Name;

            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest(new { message = "Error updating the phase." }));
        }
        public async Task <IActionResult> Update([FromRoute] string id, [FromBody] IssueUpdateDto dto)
        {
            var issue = await _repo.GetIssue(id);

            if (dto.Labels != null)
            {
                issue.IssueLabels = new List <IssueLabel>();
                foreach (var labelId in dto.Labels)
                {
                    var label = await _repo.GetLabel(labelId);

                    issue.IssueLabels.Add(new IssueLabel
                    {
                        IssueId = id,
                        LabelId = labelId,
                        Label   = label
                    });
                }
            }

            var phase = await _repo.GetPhase(dto.PhaseId);

            if (phase == null)
            {
                return(BadRequest());
            }

            issue.Name        = dto.Name;
            issue.Description = dto.Description;
            issue.IssueType   = dto.IssueType;
            issue.DueDate     = dto.DueDate;
            issue.PhaseId     = dto.PhaseId;

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest(new { message = "Error updating the issue." }));
        }