Hinzufügen von „Get Alive“-Anfragen mit MediatR-Erweiterungsmethode ohne Handler

This commit is contained in:
tekh 2025-07-07 15:25:07 +02:00
parent fd6e6d474d
commit 1699cca53d
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,13 @@
using MediatR;
namespace Leanetec.EConnect.Client.Alive;
public record GetRequest(Role? Role = null) : IRequest<bool>
{
}
public enum Role
{
User,
Admin
}

View File

@ -0,0 +1,17 @@
using MediatR;
namespace Leanetec.EConnect.Client.Alive;
public static class MediatRExtensions
{
/// <summary>
/// Returns true if while the application is up.
/// </summary>
/// <param name="mediator"></param>
/// <param name="role">Role of logged user</param>
/// <returns></returns>
public static Task<bool> IsAliveAsync(this IMediator mediator, Role? role = null)
{
return mediator.Send(new GetRequest(role));
}
}