Add synchronous versions of article retrieval methods with XML documentation and regions
This commit is contained in:
parent
7d5c00f0cb
commit
71f7039376
@ -8,6 +8,8 @@ namespace Leanetec.EConnect.Client.Articles;
|
||||
/// </summary>
|
||||
public static class GetExtensions
|
||||
{
|
||||
#region GetArticleById
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a single <see cref="Article"/> by its unique identifier.
|
||||
/// </summary>
|
||||
@ -23,6 +25,25 @@ public static class GetExtensions
|
||||
return articles.FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a single <see cref="Article"/> by its unique identifier.
|
||||
/// </summary>
|
||||
/// <param name="mediator">The <see cref="IMediator"/> instance used to send the request.</param>
|
||||
/// <param name="id">The unique identifier of the article to retrieve.</param>
|
||||
/// <param name="apiVersion">Optional API version to target the request.</param>
|
||||
/// <returns>
|
||||
/// The matching <see cref="Article"/>, or <c>null</c> if not found.
|
||||
/// </returns>
|
||||
public static Article? GetArticleById(this IMediator mediator, int id, int? apiVersion = null)
|
||||
{
|
||||
var articles = mediator.Send(new GetRequest(id) { ApiVersion = apiVersion }).GetAwaiter().GetResult();
|
||||
return articles.FirstOrDefault();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetAllArticles
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all available <see cref="Article"/> entities.
|
||||
/// </summary>
|
||||
@ -35,4 +56,19 @@ public static class GetExtensions
|
||||
{
|
||||
ApiVersion = apiVersion
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all available <see cref="Article"/> entities.
|
||||
/// </summary>
|
||||
/// <param name="mediator">The <see cref="IMediator"/> instance used to send the request.</param>
|
||||
/// <param name="apiVersion">Optional API version to target the request.</param>
|
||||
/// <returns>
|
||||
/// A collection of all available <see cref="Article"/> entities.
|
||||
/// </returns>
|
||||
public static IEnumerable<Article> GetAllArticles(this IMediator mediator, int? apiVersion = null) => mediator.Send(new GetRequest()
|
||||
{
|
||||
ApiVersion = apiVersion
|
||||
}).GetAwaiter().GetResult();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user