コード例 #1
0
        public async Task <ActionResult <LabelCreateResult> > CreateMilestone(
            string toOwnerName, string toRepoName,
            [FromBody] MilestoneCreateRequest milestoneCreateRequest)
        {
            try
            {
                var milestoneCreateResult = await IssueMoverService.CreateMilestone(toOwnerName, toRepoName, milestoneCreateRequest);

                return(Ok(milestoneCreateResult));
            }
            catch (Exception ex)
            {
                return(BadRequest(
                           new MilestoneCreateResult
                {
                    ExceptionMessage = ex.Message,
                    ExceptionStackTrace = ex.StackTrace,
                }));
            }
        }
コード例 #2
0
        public async Task <ActionResult <LabelCreateResult> > CreateMilestone(
            string toOwnerName, string toRepoName,
            [FromBody] MilestoneCreateRequest milestoneCreateRequest)
        {
            var accessToken = await HttpContext.GetTokenAsync("access_token");

            var gitHub = GitHubUtils.GetGitHubClient(accessToken);

            var destinationMilestones = await gitHub.Issue.Milestone.GetAllForRepository(toOwnerName, toRepoName);

            if (destinationMilestones.Any(m => string.Equals(m.Title, milestoneCreateRequest.Milestone, StringComparison.OrdinalIgnoreCase)))
            {
                // Milestone already exists, so do nothing
                return(Ok(new MilestoneCreateResult
                {
                    MilestoneCreated = null,
                }));
            }

            try
            {
                await gitHub.Issue.Milestone.Create(toOwnerName, toRepoName, new NewMilestone(milestoneCreateRequest.Milestone));

                return(Ok(
                           new MilestoneCreateResult
                {
                    MilestoneCreated = milestoneCreateRequest.Milestone,
                }));
            }
            catch (Exception ex)
            {
                return(BadRequest(
                           new MilestoneCreateResult
                {
                    Exception = ex,
                }));
            }
        }
コード例 #3
0
        public async Task <MilestoneCreateResult> CreateMilestone(string destinationOwner, string destinationRepo, MilestoneCreateRequest milestoneCreateRequest)
        {
            var gitHub = await GitHubAccessor.GetGitHubClient();

            var destinationMilestones = await gitHub.Issue.Milestone.GetAllForRepository(destinationOwner, destinationRepo);

            if (destinationMilestones.Any(m => string.Equals(m.Title, milestoneCreateRequest.Milestone, StringComparison.OrdinalIgnoreCase)))
            {
                // Milestone already exists, so do nothing
                return(new MilestoneCreateResult
                {
                    MilestoneCreated = null,
                });
            }

            await gitHub.Issue.Milestone.Create(destinationOwner, destinationRepo, new NewMilestone(milestoneCreateRequest.Milestone));

            return(new MilestoneCreateResult
            {
                MilestoneCreated = milestoneCreateRequest.Milestone,
            });
        }
コード例 #4
0
 public async Task <MilestoneCreateResult> CreateMilestone(string destinationOwner, string destinationRepo, MilestoneCreateRequest milestoneCreateRequest)
 {
     return(await Http.PostJsonAsync <MilestoneCreateResult>($"https://localhost:44347/api/createmilestone/{destinationOwner}/{destinationRepo}", milestoneCreateRequest));
 }