Hinzufügen von „Get Alive“-Anfragen mit MediatR-Erweiterungsmethode ohne Handler
This commit is contained in:
parent
fd6e6d474d
commit
1699cca53d
13
src/Leanetec.EConnect.Client/Alive/GetRequest.cs
Normal file
13
src/Leanetec.EConnect.Client/Alive/GetRequest.cs
Normal 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
|
||||
}
|
||||
17
src/Leanetec.EConnect.Client/Alive/MediatRExtensions.cs
Normal file
17
src/Leanetec.EConnect.Client/Alive/MediatRExtensions.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user