get support :)

This commit is contained in:
David Lebee 2021-02-05 14:05:18 -05:00
parent 7a67866dc3
commit cc0b01bfee
4 changed files with 48 additions and 3 deletions

View File

@ -13,9 +13,9 @@ namespace PoweredSoft.CQRS.AspNetCore.OData
where TQuery : class
{
[EnableQuery, HttpGet, QueryControllerAuthorization]
public async Task<TQueryResult> Get([FromServices]IQueryHandler<TQuery, TQueryResult> queryHandler)
public async Task<TQueryResult> Get([FromServices]IQueryHandler<TQuery, TQueryResult> queryHandler, [FromQuery]TQuery query)
{
var result = await queryHandler.HandleAsync(null, HttpContext.RequestAborted);
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
return result;
}
}

View File

@ -19,6 +19,17 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc
return BadRequest(ModelState);
return Ok(await handler.HandleAsync(query, this.Request.HttpContext.RequestAborted));
}
[HttpGet, QueryControllerAuthorization]
public async Task<ActionResult<TQueryResult>> HandleGet([FromServices] IQueryHandler<TQuery, TQueryResult> handler,
[FromQuery] TQuery query)
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
return Ok(await handler.HandleAsync(query, this.Request.HttpContext.RequestAborted));
}
}

View File

@ -1,4 +1,5 @@
using PoweredSoft.DynamicQuery;
using Microsoft.AspNetCore.Mvc;
using PoweredSoft.DynamicQuery;
using PoweredSoft.DynamicQuery.Core;
using System.Collections.Generic;
using System.Linq;
@ -15,6 +16,19 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore
public string Path { get; set; }
public object Value { get; set; }
[FromQuery(Name ="value")]
public string QueryValue
{
get
{
return null;
}
set
{
Value = value;
}
}
public IFilter ToFilter()
{
if (Type == FilterType.Composite)

View File

@ -23,6 +23,16 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
return result;
}
[HttpGet, QueryControllerAuthorization]
public async Task<IQueryExecutionResult<TDestination>> HandleGetAsync(
[FromQuery] DynamicQuery<TSource, TDestination> query,
[FromServices] PoweredSoft.CQRS.Abstractions.IQueryHandler<IDynamicQuery<TSource, TDestination>, IQueryExecutionResult<TDestination>> queryHandler
)
{
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
return result;
}
}
[ApiController, Route("api/query/[controller]")]
@ -40,5 +50,15 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
return result;
}
[HttpGet, QueryControllerAuthorization]
public async Task<IQueryExecutionResult<TDestination>> HandleGetAsync(
[FromQuery] DynamicQuery<TSource, TDestination, TParams> query,
[FromServices] PoweredSoft.CQRS.Abstractions.IQueryHandler<IDynamicQuery<TSource, TDestination, TParams>, IQueryExecutionResult<TDestination>> queryHandler
)
{
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
return result;
}
}
}