Skip to content

Commit

Permalink
Support loading single work item
Browse files Browse the repository at this point in the history
  • Loading branch information
twenzel committed Sep 27, 2022
1 parent f7c0208 commit 785b985
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,25 @@ public IEnumerable<AzureDevOpsWorkItem> GetWorkItems(IEnumerable<int> workItemId
.Select(x => new AzureDevOpsWorkItem(this.log, new AzureDevOpsWorkItemSettings(this.settings), x, this.workItemTrackingClientFactory));
}
}

/// <summary>
/// Gets the specified work item.
/// </summary>
/// <param name="workItemId">The ID of the work item.</param>
/// <returns>The work item specified by the ID.</returns>
public AzureDevOpsWorkItem GetWorkItem(int workItemId)
{
using (var workItemTrackingClient = this.workItemTrackingClientFactory.CreateWorkItemTrackingClient(this.settings.CollectionUrl, this.settings.Credentials))
{
var workItem =
workItemTrackingClient
.GetWorkItemAsync(workItemId, expand: Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItemExpand.Relations)
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();

return new AzureDevOpsWorkItem(this.log, new AzureDevOpsWorkItemSettings(this.settings), workItem, this.workItemTrackingClientFactory);
}
}
}
}

0 comments on commit 785b985

Please sign in to comment.