-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Ali-YousefiTelori/develop
Support for Filter and readablequesry controller
- Loading branch information
Showing
14 changed files
with
377 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
<Platforms>AnyCPU;x64;x86</Platforms> | ||
<Authors>EasyMicroservices</Authors> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>0.0.0.17</Version> | ||
<Version>0.0.0.18</Version> | ||
<Description>asp core servces.</Description> | ||
<Copyright>[email protected]</Copyright> | ||
<PackageTags>core,cores,base,database,services,asp,aspnet</PackageTags> | ||
|
116 changes: 116 additions & 0 deletions
116
src/CSharp/EasyMicroservices.Cores.AspCoreApi/ReadableQueryServiceController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using EasyMicroservices.Cores.Contracts.Requests; | ||
using EasyMicroservices.Cores.Database.Interfaces; | ||
using EasyMicroservices.ServiceContracts; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace EasyMicroservices.Cores.AspCoreApi | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="TEntity"></typeparam> | ||
/// <typeparam name="TFilterContract"></typeparam> | ||
/// <typeparam name="TResponseContract"></typeparam> | ||
/// <typeparam name="TId"></typeparam> | ||
[ApiController] | ||
[Route("api/[controller]/[action]")] | ||
public class ReadableQueryServiceController<TEntity, TFilterContract, TResponseContract, TId> : ControllerBase | ||
where TFilterContract : FilterRequestContract | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
protected IContractReadableLogic<TEntity, TResponseContract, TId> ContractLogic { get; private set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="contractReadable"></param> | ||
public ReadableQueryServiceController(IContractReadableLogic<TEntity, TResponseContract, TId> contractReadable) | ||
{ | ||
ContractLogic = contractReadable; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
[HttpPost] | ||
public virtual Task<MessageContract<TResponseContract>> GetById(GetIdRequestContract<TId> request, CancellationToken cancellationToken = default) | ||
{ | ||
return ContractLogic.GetById(request, OnGetQuery(), cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
[HttpPost] | ||
public virtual Task<MessageContract<TResponseContract>> GetByUniqueIdentity(GetUniqueIdentityRequestContract request, CancellationToken cancellationToken = default) | ||
{ | ||
return ContractLogic.GetByUniqueIdentity(request, OnGetQuery(), cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="filterRequest"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
[HttpPost] | ||
public virtual Task<ListMessageContract<TResponseContract>> Filter(TFilterContract filterRequest, CancellationToken cancellationToken = default) | ||
{ | ||
return ContractLogic.Filter(filterRequest, OnGetAllQuery(), cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
[HttpGet] | ||
public virtual Task<ListMessageContract<TResponseContract>> GetAll(CancellationToken cancellationToken = default) | ||
{ | ||
return ContractLogic.GetAll(OnGetAllQuery(), cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
[HttpPost] | ||
public virtual Task<ListMessageContract<TResponseContract>> GetAllByUniqueIdentity(GetUniqueIdentityRequestContract request, CancellationToken cancellationToken = default) | ||
{ | ||
return ContractLogic.GetAllByUniqueIdentity(request, OnGetAllQuery(), cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <returns></returns> | ||
protected virtual Func<IQueryable<TEntity>, IQueryable<TEntity>> OnGetQuery() | ||
{ | ||
return null; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <returns></returns> | ||
protected virtual Func<IQueryable<TEntity>, IQueryable<TEntity>> OnGetAllQuery() | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/CSharp/EasyMicroservices.Cores.Contracts/Contracts/Requests/FilterRequestContract.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
|
||
namespace EasyMicroservices.Cores.Contracts.Requests | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class FilterRequestContract | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public bool? IsDeleted { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public DateTime? FromDeletedDateTime { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public DateTime? ToDeletedDateTime { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public DateTime? FromCreationDateTime { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public DateTime? ToCreationDateTime { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public DateTime? FromModificationDateTime { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public DateTime? ToModificationDateTime { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public string UniqueIdentity { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public long? Index { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public long? Length { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public string SortColumnName { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public bool IsDescending { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ | |
<Platforms>AnyCPU;x64;x86</Platforms> | ||
<Authors>EasyMicroservices</Authors> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>0.0.0.4</Version> | ||
<Description>core.</Description> | ||
<Version>0.0.0.5</Version> | ||
<Description>core contracts.</Description> | ||
<Copyright>[email protected]</Copyright> | ||
<PackageTags>core,cores,base</PackageTags> | ||
<PackageTags>core,cores,base,contract,contracts,dto,dtos</PackageTags> | ||
<PackageProjectUrl>https://github.com/EasyMicroservices/Cores</PackageProjectUrl> | ||
<LangVersion>latest</LangVersion> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.