get support :)
This commit is contained in:
parent
7a67866dc3
commit
cc0b01bfee
@ -13,9 +13,9 @@ namespace PoweredSoft.CQRS.AspNetCore.OData
|
|||||||
where TQuery : class
|
where TQuery : class
|
||||||
{
|
{
|
||||||
[EnableQuery, HttpGet, QueryControllerAuthorization]
|
[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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,17 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc
|
|||||||
return BadRequest(ModelState);
|
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));
|
return Ok(await handler.HandleAsync(query, this.Request.HttpContext.RequestAborted));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using PoweredSoft.DynamicQuery;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using PoweredSoft.DynamicQuery;
|
||||||
using PoweredSoft.DynamicQuery.Core;
|
using PoweredSoft.DynamicQuery.Core;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -15,6 +16,19 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore
|
|||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
|
|
||||||
|
[FromQuery(Name ="value")]
|
||||||
|
public string QueryValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IFilter ToFilter()
|
public IFilter ToFilter()
|
||||||
{
|
{
|
||||||
if (Type == FilterType.Composite)
|
if (Type == FilterType.Composite)
|
||||||
|
@ -23,6 +23,16 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc
|
|||||||
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
|
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
|
||||||
return result;
|
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]")]
|
[ApiController, Route("api/query/[controller]")]
|
||||||
@ -40,5 +50,15 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc
|
|||||||
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
|
var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted);
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user