Add synchronous versions of article retrieval methods with XML documentation and regions
This commit is contained in:
@@ -8,6 +8,8 @@ namespace Leanetec.EConnect.Client.Articles;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class GetExtensions
|
public static class GetExtensions
|
||||||
{
|
{
|
||||||
|
#region GetArticleById
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves a single <see cref="Article"/> by its unique identifier.
|
/// Retrieves a single <see cref="Article"/> by its unique identifier.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -23,6 +25,25 @@ public static class GetExtensions
|
|||||||
return articles.FirstOrDefault();
|
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>
|
/// <summary>
|
||||||
/// Retrieves all available <see cref="Article"/> entities.
|
/// Retrieves all available <see cref="Article"/> entities.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -35,4 +56,19 @@ public static class GetExtensions
|
|||||||
{
|
{
|
||||||
ApiVersion = apiVersion
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user