37 lines
974 B
C#
37 lines
974 B
C#
using Pilz.Net.Api;
|
|
using Pilz.Net.Api.Messages;
|
|
|
|
namespace Pilz.Net.Extensions;
|
|
|
|
public static class ApiMessageExtensions
|
|
{
|
|
public static ApiResult ToItemResult<T>(this T? @this)
|
|
{
|
|
if (@this == null)
|
|
return ApiResult.NotFound();
|
|
return ApiResult.Ok(@this.ToItemMsg());
|
|
}
|
|
|
|
public static ApiResult ToItemsResult<T>(this IEnumerable<T>? @this)
|
|
{
|
|
if (@this == null)
|
|
return ApiResult.NotFound();
|
|
return ApiResult.Ok(@this.ToItemsMsg());
|
|
}
|
|
|
|
public static GeneralItemMessages<T>.Item ToItemMsg<T>(this T @this)
|
|
{
|
|
return new GeneralItemMessages<T>.Item(@this);
|
|
}
|
|
|
|
public static GeneralItemMessages<T>.Items ToItemsMsg<T>(this IEnumerable<T> @this)
|
|
{
|
|
return new GeneralItemMessages<T>.Items([.. @this]);
|
|
}
|
|
|
|
public static GeneralItemMessages<T>.Items ToItemsMsg<T>(this T[] @this)
|
|
{
|
|
return new GeneralItemMessages<T>.Items([.. @this]);
|
|
}
|
|
}
|