public async Task <Result <int> > CreateMergeRequest(CreateMergeRequestParameters parameters) { var client = await _clientFactory.Create(); int?projecId = await GetProjectId(client, parameters.Project); if (!projecId.HasValue) { return(Result.Fail <int>($"Project {parameters.Project} was not found")); } int?assigneeId = await GetUserId(client, parameters.AssignedToCurrentUser, parameters.Assignee); var createdMergeRequest = await client.MergeRequests.CreateAsync( new CreateMergeRequest( projecId.Value.ToString(), parameters.SourceBranch, parameters.TargetBranch, parameters.Title) { AssigneeId = assigneeId }); return(Result.Ok(createdMergeRequest.Iid)); }
public async Task <Result <int> > CreateIssue(CreateIssueParameters parameters) { var client = await _clientFactory.Create(); string projectId = await GetProjectId(client, parameters.Project); if (projectId == null) { return(Result.Fail <int>($"Project {parameters.Project} was not found")); } int?assigneeId = await GetUserId(client, parameters.AssignedToCurrentUser, parameters.Assignee); var createdIssue = await client.Issues.CreateAsync(new CreateIssueRequest(projectId, parameters.Title) { Description = parameters.Description, Labels = parameters.Labels, Assignees = assigneeId.HasValue ? new List <int> { assigneeId.Value } : null, }); return(Result.Ok(createdIssue.Iid)); }