public Issue Edit(string user, string password, string repo, int id, IssueEdit editIssue)
        {
            var client = new HttpClient();
            var uri = String.Format("https://api.github.com/repos/{0}/{1}/issues/{2}", user, repo, id);
            var request = new HttpRequestMessage<IssueEdit>(editIssue,
                                                                        new HttpMethod("PATCH"),
                                                                        new Uri(uri),
                                                                        new List<MediaTypeFormatter> { new JsonMediaTypeFormatter() });

            request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            client.DefaultRequestHeaders.Authorization = CreateBasicAuthentication(user, password);
            var response = client.SendAsync(request).Result;
            var result = response.Content.ReadAsAsync<Issue>().Result;

            return result;
        }
Пример #2
0
        public static void Main()
        {
            // Settings needed to connect and use the Regular Service.
            string user = ConfigurationManager.AppSettings["User"];
            string password = ConfigurationManager.AppSettings["Password"];
            string serviceEndpointAddress = ConfigurationManager.AppSettings["ServiceEndpointAddress"];

            // Creation of a channel connected to the Regular Service.
            var endpoint = new EndpointAddress(serviceEndpointAddress);
            var binding = new BasicHttpBinding();
            ChannelFactory<IGitHubSoapService> channelFactory = new ChannelFactory<IGitHubSoapService>(binding, endpoint);
            channelFactory.Endpoint.Behaviors.Add(new AuthenticationHeaderBehavior());
            var serviceChannel = channelFactory.CreateChannel();

            // Create a new repository.
            var newRepo = new RepoCreate
                              {
                                  name = "Test-Repository",
                                  description = "Just a test repository",
                                  has_downloads = true,
                                  has_issues = true,
                                  has_wiki = false,
                                  @private = false
                              };

            var createdRepo = serviceChannel.CreateRepo(user, password, newRepo);

            // Get the created repository.
            var repo = serviceChannel.GetRepo(user, "Test-Repository");

            // Edit the repository.
            var editRepo = new RepoEdit { has_downloads = false, name = "Test-Repository" };
            serviceChannel.EditRepo(user, password, "Test-Repository", editRepo);

            // Create an issue in the created repository.
            var newIssue = new IssueCreate {title = "Found a bug", body = "I'm having a problem with this.", assignee = "luismdcp"};
            var createdIssue = serviceChannel.CreateIssue(user, password, "Test-Repository", newIssue);

            // Edit the created issue.
            var editIssue = new IssueEdit {milestone = 1};
            serviceChannel.EditIssue(user, password, "Test-Repository", createdIssue.id, editIssue);
        }
Пример #3
0
 public Issue Edit(string user, string password, string repo, int id, IssueEdit editIssue)
 {
     return this.issuesRepository.Edit(user, password, repo, id, editIssue);
 }
 public Issue EditIssue(string user, string password, string repo, int id, IssueEdit editIssue)
 {
     IIssuesService issuesService = ObjectFactory.GetInstance<IIssuesService>();
     return issuesService.Edit(user, password, repo, id, editIssue);
 }