2021-02-05 13:06:34 -05:00
|
|
|
|
using Microsoft.AspNet.OData;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using PoweredSoft.CQRS.Abstractions;
|
|
|
|
|
using PoweredSoft.CQRS.AspNetCore.Mvc;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace PoweredSoft.CQRS.AspNetCore.OData
|
|
|
|
|
{
|
|
|
|
|
[Route("api/odata/[controller]")]
|
|
|
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
|
|
|
|
public class QueryODataController<TQuery, TQueryResult> : ODataController
|
|
|
|
|
where TQuery : class
|
|
|
|
|
{
|
|
|
|
|
[EnableQuery, HttpGet, QueryControllerAuthorization]
|
2021-02-05 14:05:18 -05:00
|
|
|
|
public async Task<TQueryResult> Get([FromServices]IQueryHandler<TQuery, TQueryResult> queryHandler, [FromQuery]TQuery query)
|
2021-02-05 13:06:34 -05:00
|
|
|
|
{
|
2021-02-05 14:05:18 -05:00
|
|
|
|
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
|
2021-02-05 13:06:34 -05:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|