master
Tudor Stanciu 2022-03-04 18:21:59 +02:00
parent be4ce6cc83
commit 53c6ad4a46
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,44 @@
using MediatR;
using ProxmoxConnector.Integration.Abstractions;
using ProxmoxConnector.Server.Application.Utils;
using System.Threading;
using System.Threading.Tasks;
namespace ProxmoxConnector.Server.Application.Queries
{
public class TestQ
{
public class Query : Query<Model>
{
public Query()
{
}
}
public class Model
{
public string Msg { get; set; }
}
public class QueryHandler : IRequestHandler<Query, Model>
{
private readonly IPveConnector _pveConnector;
public QueryHandler(IPveConnector pveConnector)
{
_pveConnector=pveConnector;
}
public QueryHandler()
{
}
public async Task<Model> Handle(Query request, CancellationToken cancellationToken)
{
await _pveConnector.TestWithLogin();
return await Task.FromResult(new Model() { Msg = "-!-" });
}
}
}
}

View File

@ -0,0 +1,29 @@
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ProxmoxConnector.Server.Application.Queries;
using System.Threading.Tasks;
namespace ProxmoxConnector.Server.Controllers
{
[Authorize]
[ApiController]
[Route("connector")]
public class ConnectorController : ControllerBase
{
private readonly IMediator _mediator;
public ConnectorController(IMediator mediator)
{
_mediator=mediator;
}
[AllowAnonymous]
[HttpGet("test")]
public async Task<IActionResult> TestQ([FromRoute] TestQ.Query query)
{
var result = await _mediator.Send(query);
return Ok(result);
}
}
}