コード例 #1
0
        public Issue UpdateIssue([NotNull] UpdateIssueRequest updateIssue)
        {
            if (updateIssue == null)
            {
                throw new ArgumentNullException(nameof(updateIssue));
            }

            var gitHubClient = GetClient();

            var intIssueId = int.Parse(updateIssue.Id);

            var issueUpdate = new IssueUpdate
            {
                Body  = updateIssue.Description,
                State = updateIssue.Status.ToState(),
                Title = updateIssue.Title
            };

            var result = gitHubClient.Issue.Update(
                GetSetting(GitHubItSettingKeys.RepositoryOwner),
                GetSetting(GitHubItSettingKeys.RepositoryName),
                intIssueId,
                issueUpdate)
                         .Result;

            return(result.ToModel());
        }
コード例 #2
0
        /// <summary>
        ///     Updates the issue.
        /// </summary>
        /// <param name="updateIssueRequest">The update issue.</param>
        /// <returns></returns>
        public Issue UpdateIssue(UpdateIssueRequest updateIssueRequest)
        {
            if (updateIssueRequest == null)
            {
                throw new ArgumentNullException(nameof(updateIssueRequest));
            }

            var client = GetClient();

            var project = GetProject(client);

            var issue = GetIssue(updateIssueRequest.Id, client, project);

            if (issue == null)
            {
                return(null);
            }

            var updatedIssue = client.Issues.Update(
                project.Id,
                issue.Id,
                new UpdateIssue
            {
                Description = updateIssueRequest.Description,
                Title       = updateIssueRequest.Title,
                State       = updateIssueRequest.Status.AsString()
            }).Result;

            return(ToDto(updatedIssue.Data));
        }
コード例 #3
0
        public Issue UpdateIssue([NotNull] UpdateIssueRequest updateIssue)
        {
            if (updateIssue == null)
            {
                throw new ArgumentNullException(nameof(updateIssue));
            }

            var wis = GetStore();

            var workItemidNumber = int.Parse(updateIssue.Id);

            var workItem = wis.GetWorkItem(workItemidNumber);

            if (workItem == null)
            {
                throw new TeamFoundationIssueDoesNotExistsException(GetSetting(TfsSettings.HostName),
                                                                    GetSetting(TfsSettings.Project),
                                                                    updateIssue.Id);
            }

            workItem.Title       = updateIssue.Title;
            workItem.Description = updateIssue.Description;

            switch (updateIssue.Status)
            {
            case IssueStatus.Closed:
                if (workItem.State != WorkItemStatuses.Closed)
                {
                    workItem.State = WorkItemStatuses.Closed;
                }
                break;

            case IssueStatus.Open:
                if (workItem.State == WorkItemStatuses.Closed)
                {
                    workItem.State = WorkItemStatuses.Active;
                }
                break;

            case IssueStatus.Unknown:
                break;

            case IssueStatus.New:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            workItem.Save();

            return(GetIssue(workItem));
        }
コード例 #4
0
        public void ShouldUpdateIssueOnGitHub()
        {
            var dateTimeString = DateTime.Now.ToString(CultureInfo.InvariantCulture);

            var updateRequest = new UpdateIssueRequest
            {
                Description = $"Updated in {dateTimeString}",
                Id          = 1.ToString(),
                Status      = IssueStatus.Closed,
                Title       = dateTimeString
            };

            var result = _target.UpdateIssue(updateRequest);

            result.Should().NotBeNull();
            result.Description.ShouldBeEquivalentTo(updateRequest.Description);
            result.Status.ShouldBeEquivalentTo(updateRequest.Status);
            result.Title.ShouldBeEquivalentTo(updateRequest.Title);
        }
コード例 #5
0
ファイル: IssueController.cs プロジェクト: inshapardaz/api
        public async Task <IActionResult> UpdateIssue(int libraryId, int periodicalId, int volumeNumber, int issueNumber, [FromBody] IssueView issue, CancellationToken token = default(CancellationToken))
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            var request = new UpdateIssueRequest(libraryId, periodicalId, volumeNumber, issueNumber, issue.Map());
            await _commandProcessor.SendAsync(request, cancellationToken : token);

            var renderResult = _issueRenderer.Render(request.Result.Issue, libraryId);

            if (request.Result.HasAddedNew)
            {
                return(new CreatedResult(renderResult.Links.Self(), renderResult));
            }
            else
            {
                return(new OkObjectResult(renderResult));
            }
        }
コード例 #6
0
        /// <summary>
        ///     Updates the issue.
        /// </summary>
        /// <param name="updateIssue">The update issue.</param>
        /// <returns></returns>
        public Issue UpdateIssue(UpdateIssueRequest updateIssue)
        {
            var client = GetClient();

            var projectUuid = GetProjectUuid(client);

            var states = client.Issues.GetStates(projectUuid).Result;

            ValidateResponse(states, HttpStatusCode.OK);

            var issue = client.Issues.Update(
                Convert.ToInt64(updateIssue.Id),
                new ChangeWorkItem
            {
                Description   = updateIssue.Description,
                Title         = updateIssue.Title,
                StateResource = updateIssue.Status.ToDto(states.Data)
            }).Result;

            ValidateResponse(issue, HttpStatusCode.OK);

            return(issue.Data.ToDto(states.Data));
        }
コード例 #7
0
 /// <summary>
 /// Updated existing issue.
 /// </summary>
 /// <returns>The updated issue.</returns>
 /// <param name="projectId">The ID, path or <see cref="Project"/> of the project.</param>
 /// <param name="issueIid">The IID of an issue.</param>
 /// <param name="request">Update issue request.</param>
 public async Task <Issue> UpdateAsync(ProjectId projectId, int issueIid, UpdateIssueRequest request) =>
 await _httpFacade.Put <Issue>($"projects/{projectId}/issues/{issueIid}", request);
コード例 #8
0
        public async Task <IActionResult> UpdateByUserProject([FromRoute] string username, [FromRoute] string projectName, [FromRoute] int issueNumber, UpdateIssueRequest issueRequest)
        {
            var issue = await _issueService.GetIssueByUserAsync(username, projectName, issueNumber).ConfigureAwait(false);

            if (issue == null)
            {
                return(NotFound());
            }
            var userId = HttpContext.GetUserId();

            if (userId != issue.AuthorId)
            {
                return(Unauthorized());
            }

            issue.Title     = issueRequest?.Title;
            issue.UpdatedAt = DateTime.UtcNow;
            issue.Content   = issueRequest.Content;

            var updated = await _issueService.UpdateIssueAsync(issue, issueRequest.Types).ConfigureAwait(false);

            if (!updated)
            {
                return(NotFound());
            }

            var locationUri = _uriService.GetUri(issue.Number.ToString());

            return(Created(locationUri, new Response <IssueResponse>(_mapper.Map <IssueResponse>(issue))));
        }
コード例 #9
0
 /// <summary>
 /// Updated existing issue.
 /// </summary>
 /// <returns>The updated issue.</returns>
 public async Task <Issue> UpdateAsync(UpdateIssueRequest request) =>
 await _httpFacade.Put <Issue>($"projects/{request.ProjectId}/issues/{request.IssueId}", request);