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, })); } }
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, })); } }
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, }); }
public async Task <MilestoneCreateResult> CreateMilestone(string destinationOwner, string destinationRepo, MilestoneCreateRequest milestoneCreateRequest) { return(await Http.PostJsonAsync <MilestoneCreateResult>($"https://localhost:44347/api/createmilestone/{destinationOwner}/{destinationRepo}", milestoneCreateRequest)); }