using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using PoweredSoft.CQRS.Abstractions; using PoweredSoft.CQRS.AspNetCore.Mvc; using PoweredSoft.CQRS.DynamicQuery.Abstractions; using PoweredSoft.DynamicQuery.Core; namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc { [ApiController, Route("api/query/[controller]")] public class DynamicQueryController : Controller where TSource : class where TDestination : class { [HttpPost, QueryControllerAuthorization] public async Task> HandleAsync( [FromBody] DynamicQuery query, [FromServices]IQueryHandler, IQueryExecutionResult> queryHandler ) { var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); return result; } [HttpGet, QueryControllerAuthorization] public async Task> HandleGetAsync( [FromQuery] DynamicQuery query, [FromServices] IQueryHandler, IQueryExecutionResult> queryHandler ) { var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); return result; } } [ApiController, Route("api/query/[controller]")] public class DynamicQueryController : Controller where TSource : class where TDestination : class where TParams : class { [HttpPost, QueryControllerAuthorization] public async Task> HandleAsync( [FromBody] DynamicQuery query, [FromServices] IQueryHandler, IQueryExecutionResult> queryHandler ) { var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); return result; } [HttpGet, QueryControllerAuthorization] public async Task> HandleGetAsync( [FromQuery] DynamicQuery query, [FromServices] IQueryHandler, IQueryExecutionResult> queryHandler ) { var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); return result; } } }