diff --git a/Controllers/XBaseIdentityApiController.cs b/Controllers/XBaseIdentityApiController.cs new file mode 100644 index 0000000..40f9eca --- /dev/null +++ b/Controllers/XBaseIdentityApiController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using xCommons.Attributes; +using xCommons.Configurations; +using xCommons.Providers; +using xIdentityService.Interfaces; + +namespace xIdentityService.Controllers +{ + /// + /// Base Identity Api Controller + /// + [ApiController] + [RequireXPowered(true)] + [Route("api/[controller]")] + [Produces("application/json")] + public abstract class XBaseIdentityApiController : XBaseIdentityController + { + protected XBaseIdentityApiController( + ILogger logger, + XAppConfiguration appConfiguration, + IXIdentityProvider identityProvider, + XValidationProvider validationProvider + ) : base( + logger, + appConfiguration, + identityProvider, + validationProvider + ) + { } + } +} \ No newline at end of file diff --git a/Controllers/XIBaseProviderController.cs b/Controllers/XBaseIdentityApiV1Controller.cs similarity index 59% rename from Controllers/XIBaseProviderController.cs rename to Controllers/XBaseIdentityApiV1Controller.cs index a68adfc..006c443 100644 --- a/Controllers/XIBaseProviderController.cs +++ b/Controllers/XBaseIdentityApiV1Controller.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using xCommons.Attributes; using xCommons.Configurations; @@ -7,11 +7,16 @@ using xIdentityService.Interfaces; namespace xIdentityService.Controllers { - [Authorize] - [RequireXPowered(false)] - public abstract class XIBaseProviderController : XIBaseController + /// + /// Base Identity Api V1 Controller + /// + [ApiController] + [ApiVersion("1.0")] + [RequireXPowered(true)] + [Route("api/v{version:apiVersion}/[controller]")] + public abstract class XBaseIdentityApiV1Controller : XBaseIdentityApiController { - protected XIBaseProviderController( + protected XBaseIdentityApiV1Controller( ILogger logger, XAppConfiguration appConfiguration, IXIdentityProvider identityProvider, diff --git a/Controllers/XIBaseController.cs b/Controllers/XBaseIdentityController.cs similarity index 93% rename from Controllers/XIBaseController.cs rename to Controllers/XBaseIdentityController.cs index 4355f75..7af44ba 100644 --- a/Controllers/XIBaseController.cs +++ b/Controllers/XBaseIdentityController.cs @@ -16,11 +16,12 @@ using xIdentityService.Interfaces; namespace xIdentityService.Controllers { - public abstract class XIBaseController : XBaseController + public abstract class XBaseIdentityController : XBaseController { - private readonly IXIdentityProvider identityProvider; + // + public IXIdentityProvider IdentityProvider { get; } - public XIBaseController( + protected XBaseIdentityController( ILogger logger, XAppConfiguration appConfiguration, IXIdentityProvider identityProvider, @@ -31,7 +32,7 @@ namespace xIdentityService.Controllers validationProvider ) { - this.identityProvider = identityProvider; + IdentityProvider = identityProvider; } // @@ -79,10 +80,11 @@ namespace xIdentityService.Controllers ValidationProvider.NotNull(model); // - var result = identityProvider.GetUserSelectByParam( + var result = IdentityProvider.GetUserSelectByParam( model, forceNotNull, - excludes); + excludes + ); // return result; @@ -96,10 +98,10 @@ namespace xIdentityService.Controllers public async Task GetAccessToken() { // - var accessToken = Request.Headers[XAuthorization.Header] - .ToString(); + var accessToken = Request.Headers[XAuthorization.Header].ToString(); if (accessToken.IsNullOrEmpty()) { + // accessToken = await HttpContext .GetTokenAsync(XAuthorization.AccessToken); } @@ -110,6 +112,7 @@ namespace xIdentityService.Controllers .Contains(XAuthorization.TokenIdentifier .ToNormalString())) { + // accessToken = accessToken .Remove(0, XAuthorization.TokenIdentifier.Length); } @@ -126,10 +129,10 @@ namespace xIdentityService.Controllers public async Task GetRefreshToken() { // - var refreshToken = Request.Headers[XAuthorization.RefreshToken] - .ToString(); + var refreshToken = Request.Headers[XAuthorization.RefreshToken].ToString(); if (refreshToken.IsNullOrEmpty()) { + // refreshToken = await HttpContext .GetTokenAsync(XAuthorization.RefreshToken); } @@ -146,10 +149,10 @@ namespace xIdentityService.Controllers public async Task GetTokenExpiresAt() { // - var expiresAtStr = Request.Headers[XAuthorization.ExpiresAt] - .ToString(); + var expiresAtStr = Request.Headers[XAuthorization.ExpiresAt].ToString(); if (expiresAtStr.IsNullOrEmpty()) { + // expiresAtStr = await HttpContext .GetTokenAsync(XAuthorization.ExpiresAt); } diff --git a/Controllers/XIBaseDomainController.cs b/Controllers/XIBaseDomainController.cs deleted file mode 100644 index 4fde7e9..0000000 --- a/Controllers/XIBaseDomainController.cs +++ /dev/null @@ -1,714 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore.Query; -using Microsoft.Extensions.Logging; -using xCommons.Attributes; -using xCommons.Configurations; -using xCommons.Extensions; -using xCommons.Providers; -using xDataService.Interfaces; -using xExceptions.Constants; -using xIdentityService.Interfaces; -using xModels.Base; -using xModels.Dtos; - -namespace xIdentityService.Controllers -{ - // - // TODO: Complete this ... - // [Authorize] - // [RequireXPowered(false)] - // public abstract class XIBaseDomainController : XIBaseController, IXDomainControllerActions - // where TEntity : XBaseEntity - // where TDto : XBaseEntityDto - // { - // // - // #region Properties ... - // public IXBaseRepositoryService RepositoryService { get; } - // public Func, IOrderedQueryable> DefaultOrderBuilder { get; } - // public Func, IIncludableQueryable> DefaultIncludeBuilder { get; } - // #endregion - - // // - // #region Constructor ... - // protected XIBaseDomainController( - // ILogger logger, - // XAppConfiguration appConfiguration, - // IXIdentityProvider identityProvider, - // XValidationProvider validationProvider, - // IXBaseRepositoryService repositoryService, - // Func, IOrderedQueryable> defaultOrderBuilder = null, - // Func, IIncludableQueryable> defaultIncludeBuilder = null - // ) : base( - // logger, - // appConfiguration, - // identityProvider, - // validationProvider - // ) - // { - // // - // RepositoryService = repositoryService; - // DefaultOrderBuilder = defaultOrderBuilder; - // DefaultIncludeBuilder = defaultIncludeBuilder; - // } - // #endregion - - // // - // #region Actions ... - // // - // #region Add ... - // /// - // /// Add Specified Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost] - // public virtual async Task> Add( - // [FromBody] TDto item, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // ValidationProvider.NotNull(item); - - // // - // // Get Result ... - // var result = await RepositoryService - // .AddAsync( - // item, - // saveChanges: true, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Add or Update Specified Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost("AddOrUpdate")] - // public virtual async Task> AddOrUpdate( - // [FromBody] TDto item, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // ValidationProvider.NotNull(item); - - // // - // // Get Result ... - // var result = await RepositoryService - // .AddOrUpdateAsync( - // item, - // saveChanges: true, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Add a Collection of Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost("AddMany")] - // public virtual async Task AddMany( - // [FromBody] XBaseRangeRequest request, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // await ValidationProvider - // .GroupValidationBuilder() - // .AddNotNull(request) - // .AddNotZeroChilds(request.Items) - // .ValidateGroupAsync(); - - // // - // // Get Result ... - // await RepositoryService - // .AddRangeAsync( - // request.Items, - // saveChanges: true, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - - // // - // #region Retrieve ... - // /// - // /// Get Specified Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("{id}")] - // public virtual async Task> Get( - // [FromRoute] TKey id, - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotNull(id); - - // // - // // Get Result ... - // var result = await RepositoryService - // .GetAsync( - // id, - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Get All Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet] - // public virtual async Task>> GetAll( - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultOrders = false, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Get Result ... - // var result = await RepositoryService - // .GetAllAsync( - // orderBuilder: useDefaultOrders - // ? DefaultOrderBuilder - // : null, - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Find Specified Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("FindOne/{query}")] - // public virtual async Task> FindOne( - // [FromRoute] string query, - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotEmpty(query); - - // // - // // Get Result ... - // var result = await RepositoryService - // .FindOneAsync( - // predicate: t => - // t.PropValuesContains(query), - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Find Many Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("FindMany/{query}")] - // public virtual async Task>> FindMany( - // [FromRoute] string query, - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultOrders = false, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotEmpty(query); - - // // - // // Get Result ... - // var result = await RepositoryService - // .FindManyAsync( - // predicate: t => - // t.PropValuesContains(query), - // orderBuilder: useDefaultOrders - // ? DefaultOrderBuilder - // : null, - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Retrieve Items Based on Query Mechanism ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("Query")] - // public virtual async Task>> Query( - // [FromQuery] XQuery query, - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultOrders = false, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotNull(query); - - // // - // // Get Result ... - // var result = await RepositoryService - // .QueryAsync( - // query: query, - // orderBuilder: useDefaultOrders - // ? DefaultOrderBuilder - // : null, - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - - // // - // #region Update ... - // /// - // /// Update Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPut("{id}")] - // public virtual async Task> Update( - // [FromRoute] TKey id, - // [FromBody] TDto item, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // await ValidationProvider - // .GroupValidationBuilder() - // .AddNotNull(id, item) - // .ValidateGroupAsync(); - - // // - // // Get Result ... - // var result = await RepositoryService - // .UpdateAsync( - // id: id, - // item: item, - // saveChanges: true, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Update a Collection of items ... - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost("UpdateMany")] - // public virtual async Task> UpdateMany( - // [FromBody] XBaseRangeRequest request, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // await ValidationProvider - // .GroupValidationBuilder() - // .AddNotNull(request) - // .AddNotZeroChilds(request.Items) - // .ValidateGroupAsync(); - - // // - // // Get Result ... - // var result = await RepositoryService - // .UpdateRangeAsync( - // saveChanges: true, - // items: request.Items, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - - // // - // #region Exists ... - // /// - // ///Check an Item Exists or not ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("{id}/IsExists")] - // public virtual async Task> IsExists( - // [FromRoute] TKey id, - // [FromQuery] bool ignoreSoftDeleteds = true, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotNull(id); - - // // - // // Get Result ... - // var result = await RepositoryService - // .IsExistsAsync( - // id: id, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - - // // - // #region Remove ... - // /// - // /// Remove an Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpDelete("{id}")] - // public virtual async Task> Remove( - // [FromRoute] TKey id, - // [FromQuery] bool softDelete = true, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotNull(id); - - // // - // // Get Result ... - // var result = await RepositoryService - // .RemoveAsync( - // id: id, - // saveChanges: true, - // softDelete: softDelete, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Remove Many Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost("RemoveMany")] - // public virtual async Task RemoveMany( - // [FromBody] XBaseRangeRequest request, - // [FromQuery] bool softDelete = true, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // await ValidationProvider - // .GroupValidationBuilder() - // .AddNotNull(request) - // .AddNotZeroChilds(request.Items) - // .ValidateGroupAsync(); - - // // - // // Get Result ... - // await RepositoryService - // .RemoveRangeAsync( - // saveChanges: true, - // items: request.Items, - // softDelete: softDelete, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - // #endregion - // } -} \ No newline at end of file diff --git a/Controllers/XIBaseEntityController.cs b/Controllers/XIBaseEntityController.cs deleted file mode 100644 index e4b3bca..0000000 --- a/Controllers/XIBaseEntityController.cs +++ /dev/null @@ -1,715 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore.Query; -using Microsoft.Extensions.Logging; -using xCommons.Attributes; -using xCommons.Configurations; -using xCommons.Extensions; -using xCommons.Providers; -using xDataService.Interfaces; -using xExceptions.Constants; -using xIdentityService.Interfaces; -using xModels.Base; -using xModels.Dtos; - -namespace xIdentityService.Controllers -{ - // - // TODO: Fix This ... - // [Authorize] - // [RequireXPowered(false)] - // public abstract class XIBaseEntityController : XIBaseController, IXEntityControllerActions - // where TEntity : XBaseEntity - // { - // // - // #region Properties ... - // public IXBaseRepository Repository { get; } - - // public Func, IOrderedQueryable> DefaultOrderBuilder { get; } - - // public Func, IIncludableQueryable> DefaultIncludeBuilder { get; } - // #endregion - - // // - // #region Constructor ... - // protected XIBaseEntityController( - // ILogger logger, - // XAppConfiguration appConfiguration, - // IXIdentityProvider identityProvider, - // XValidationProvider validationProvider, - // IXBaseRepository repository, - // Func, IOrderedQueryable> defaultOrderBuilder = null, - // Func, IIncludableQueryable> defaultIncludeBuilder = null - // ) : base( - // logger, - // appConfiguration, - // identityProvider, - // validationProvider - // ) - // { - // // - // Repository = repository; - // DefaultOrderBuilder = defaultOrderBuilder; - // DefaultIncludeBuilder = defaultIncludeBuilder; - // } - // #endregion - - // // - // #region Actions ... - // // - // #region Add ... - // /// - // /// Add Specified Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost] - // public virtual async Task> Add( - // [FromBody] TEntity item, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // ValidationProvider.NotNull(item); - - // // - // // Get Result ... - // var result = await Repository - // .AddAsync( - // item, - // saveChanges: true, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Add or Update Specified Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost("AddOrUpdate")] - // public virtual async Task> AddOrUpdate( - // [FromBody] TEntity item, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // ValidationProvider.NotNull(item); - - // // - // // Get Result ... - // var result = await Repository - // .AddOrUpdateAsync( - // item, - // saveChanges: true, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Add a Collection of Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost("AddMany")] - // public virtual async Task AddMany( - // [FromBody] XBaseRangeRequest request, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // await ValidationProvider - // .GroupValidationBuilder() - // .AddNotNull(request) - // .AddNotZeroChilds(request.Items) - // .ValidateGroupAsync(); - - // // - // // Get Result ... - // await Repository - // .AddRangeAsync( - // request.Items, - // saveChanges: true, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - - // // - // #region Retrieve ... - // /// - // /// Get Specified Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("{id}")] - // public virtual async Task> Get( - // [FromRoute] TKey id, - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotNull(id); - - // // - // // Get Result ... - // var result = await Repository - // .GetAsync( - // id, - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Get All Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet] - // public virtual async Task>> GetAll( - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultOrders = false, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Get Result ... - // var result = await Repository - // .GetAllAsync( - // orderBuilder: useDefaultOrders - // ? DefaultOrderBuilder - // : null, - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Find Specified Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("FindOne/{query}")] - // public virtual async Task> FindOne( - // [FromRoute] string query, - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotEmpty(query); - - // // - // // Get Result ... - // var result = await Repository - // .FindOneAsync( - // predicate: t => - // t.PropValuesContains(query), - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Find Many Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("FindMany/{query}")] - // public virtual async Task>> FindMany( - // [FromRoute] string query, - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultOrders = false, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotEmpty(query); - - // // - // // Get Result ... - // var result = await Repository - // .FindManyAsync( - // predicate: t => - // t.PropValuesContains(query), - // orderBuilder: useDefaultOrders - // ? DefaultOrderBuilder - // : null, - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Retrieve Items Based on Query Mechanism ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("Query")] - // public virtual async Task>> Query( - // [FromQuery] XQuery query, - // [FromQuery] bool ignoreSoftDeleteds = true, - // [FromQuery] bool useDefaultOrders = false, - // [FromQuery] bool useDefaultIncludes = false, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotNull(query); - - // // - // // Get Result ... - // var result = await Repository - // .QueryAsync( - // query: query, - // orderBuilder: useDefaultOrders - // ? DefaultOrderBuilder - // : null, - // includeBuilder: useDefaultIncludes - // ? DefaultIncludeBuilder - // : null, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - - // // - // #region Update ... - // /// - // /// Update Item ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPut("{id}")] - // public virtual async Task> Update( - // [FromRoute] TKey id, - // [FromBody] TEntity item, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // await ValidationProvider - // .GroupValidationBuilder() - // .AddNotNull(id, item) - // .ValidateGroupAsync(); - - // // - // // Get Result ... - // var result = await Repository - // .UpdateAsync( - // id: id, - // item: item, - // saveChanges: true, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Update a Collection of items ... - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost("UpdateMany")] - // public virtual async Task> UpdateMany( - // [FromBody] XBaseRangeRequest request, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // if (!ModelState.IsValid) - // { - // XException.InvalidArgs.Throw(); - // } - // await ValidationProvider - // .GroupValidationBuilder() - // .AddNotNull(request) - // .AddNotZeroChilds(request.Items) - // .ValidateGroupAsync(); - - // // - // // Get Result ... - // var result = await Repository - // .UpdateRangeAsync( - // saveChanges: true, - // items: request.Items, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - - // // - // #region Exists ... - // /// - // ///Check an Item Exists or not ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpGet("{id}/IsExists")] - // public virtual async Task> IsExists( - // [FromRoute] TKey id, - // [FromQuery] bool ignoreSoftDeleteds = true, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotNull(id); - - // // - // // Get Result ... - // var result = await Repository - // .IsExistsAsync( - // id: id, - // cancellationToken: cancellationToken, - // ignoreSoftDeleteds: ignoreSoftDeleteds - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - - // // - // #region Remove ... - // /// - // /// Remove an Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpDelete("{id}")] - // public virtual async Task> Remove( - // [FromRoute] TKey id, - // [FromQuery] bool softDelete = true, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // ValidationProvider.NotNull(id); - - // // - // // Get Result ... - // var result = await Repository - // .RemoveAsync( - // id: id, - // saveChanges: true, - // softDelete: softDelete, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(result - // .ToDynamicObject()); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - - // /// - // /// Remove Many Items ... - // /// - // /// - // /// - // /// - // /// - // /// - // /// - // [HttpPost("RemoveMany")] - // public virtual async Task RemoveMany( - // [FromBody] XBaseRangeRequest request, - // [FromQuery] bool softDelete = true, - // CancellationToken cancellationToken = default - // ) - // { - // // - // try - // { - // // - // // Validate Args ... - // await ValidationProvider - // .GroupValidationBuilder() - // .AddNotNull(request) - // .AddNotZeroChilds(request.Items) - // .ValidateGroupAsync(); - - // // - // // Get Result ... - // await Repository - // .RemoveRangeAsync( - // saveChanges: true, - // items: request.Items, - // softDelete: softDelete, - // cancellationToken: cancellationToken - // ); - - // // - // return Ok(); - // } - // catch (Exception ex) - // { - // // - // var result = GetExceptionActionResult(ex); - // return result; - // } - // } - // #endregion - // #endregion - // } -} \ No newline at end of file