public async Task <Comment> AddPullRequestComment(string repositoryName, string ownerName, long id, string content, long?lineFrom = null, long?lineTo = null, string fileName = null, long?parentId = null) { var url = EnterpriseApiUrls.PullRequestComments(ownerName, repositoryName, id); var request = new YouTrackRestRequest(url, Method.POST); var body = new EnterpriseComment() { Text = content, Parent = parentId.HasValue ? new EnterpriseParent() { Id = parentId.Value } : null, Anchor = fileName != null ? new EnterpriseAnchor() { Line = lineFrom ?? lineTo, FileType = lineFrom != null && lineTo != null ? (FileDiffType?)null : lineFrom != null ? FileDiffType.From : FileDiffType.To, Path = fileName, SourcePath = fileName, LineType = lineFrom != null && lineTo != null ? "CONTEXT" : lineFrom != null ? "REMOVED" : "ADDED", } : null }; request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(body), ParameterType.RequestBody); var response = await RestClient.ExecuteTaskAsync <EnterpriseComment>(request); return(response.Data.MapTo <Comment>()); }
private static void AssignCommentParent(EnterpriseComment parent) { foreach (var child in parent.Comments) { child.Parent = new EnterpriseParent() { Id = parent.Id.Value }; AssignCommentParent(child); } }
public async Task <Comment> EditPullRequestComment(string repositoryName, string ownerName, long pullRequestId, long id, string content, long commentVersion) { var url = EnterpriseApiUrls.PullRequestComment(ownerName, repositoryName, pullRequestId, id); var request = new YouTrackRestRequest(url, Method.PUT); var body = new EnterpriseComment() { Text = content, Id = id, Version = commentVersion }; request.AddParameter("application/json; charset=utf-8", request.JsonSerializer.Serialize(body), ParameterType.RequestBody); var response = await RestClient.ExecuteTaskAsync <EnterpriseComment>(request); return(response.Data.MapTo <Comment>()); }