From 2ef7e559d7d43a5d0362327b176eefe97088c284 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 15 May 2026 02:47:52 +0330 Subject: [PATCH] Refactor ... --- Controllers/XIBaseDomainController.cs | 1304 +++++++++++++------------ Controllers/XIBaseEntityController.cs | 1302 ++++++++++++------------ 2 files changed, 1305 insertions(+), 1301 deletions(-) diff --git a/Controllers/XIBaseDomainController.cs b/Controllers/XIBaseDomainController.cs index 2e9703d..4fde7e9 100644 --- a/Controllers/XIBaseDomainController.cs +++ b/Controllers/XIBaseDomainController.cs @@ -19,694 +19,696 @@ using xModels.Dtos; namespace xIdentityService.Controllers { - [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 + // + // 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 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); + // // + // #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 - ); + // // + // // 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; - } - } + // // + // 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); + // /// + // /// 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 - ); + // // + // // 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; - } - } + // // + // 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(); + // /// + // /// 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 - ); + // // + // // Get Result ... + // await RepositoryService + // .AddRangeAsync( + // request.Items, + // saveChanges: true, + // cancellationToken: cancellationToken + // ); - // - return Ok(); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - #endregion + // // + // 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); + // // + // #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 - ); + // // + // // 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; - } - } + // // + // 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 - ); + // /// + // /// 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; - } - } + // // + // 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); + // /// + // /// 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 - ); + // // + // // 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; - } - } + // // + // 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); + // /// + // /// 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 - ); + // // + // // 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; - } - } + // // + // 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); + // /// + // /// 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 - ); + // // + // // 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 + // // + // 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(); + // // + // #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 - ); + // // + // // 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; - } - } + // // + // 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(); + // /// + // /// 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 - ); + // // + // // 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 + // // + // 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); + // // + // #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 - ); + // // + // // 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 + // // + // 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); + // // + // #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 - ); + // // + // // 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; - } - } + // // + // 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(); + // /// + // /// 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 - ); + // // + // // 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 - } + // // + // 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 index f52e243..e4b3bca 100644 --- a/Controllers/XIBaseEntityController.cs +++ b/Controllers/XIBaseEntityController.cs @@ -19,695 +19,697 @@ using xModels.Dtos; namespace xIdentityService.Controllers { - [Authorize] - [RequireXPowered(false)] - public abstract class XIBaseEntityController : XIBaseController, IXEntityControllerActions - where TEntity : XBaseEntity - { - // - #region Properties ... - public IXBaseRepository Repository { get; } + // + // 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, IOrderedQueryable> DefaultOrderBuilder { get; } - public Func, IIncludableQueryable> DefaultIncludeBuilder { get; } - #endregion + // 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 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); + // // + // #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 - ); + // // + // // 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; - } - } + // // + // 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); + // /// + // /// 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 - ); + // // + // // 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; - } - } + // // + // 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(); + // /// + // /// 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 - ); + // // + // // Get Result ... + // await Repository + // .AddRangeAsync( + // request.Items, + // saveChanges: true, + // cancellationToken: cancellationToken + // ); - // - return Ok(); - } - catch (Exception ex) - { - // - var result = GetExceptionActionResult(ex); - return result; - } - } - #endregion + // // + // 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); + // // + // #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 - ); + // // + // // 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; - } - } + // // + // 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 - ); + // /// + // /// 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; - } - } + // // + // 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); + // /// + // /// 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 - ); + // // + // // 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; - } - } + // // + // 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); + // /// + // /// 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 - ); + // // + // // 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; - } - } + // // + // 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); + // /// + // /// 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 - ); + // // + // // 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 + // // + // 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(); + // // + // #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 - ); + // // + // // 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; - } - } + // // + // 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(); + // /// + // /// 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 - ); + // // + // // 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 + // // + // 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); + // // + // #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 - ); + // // + // // 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 + // // + // 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); + // // + // #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 - ); + // // + // // 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; - } - } + // // + // 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(); + // /// + // /// 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 - ); + // // + // // 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 - } + // // + // return Ok(); + // } + // catch (Exception ex) + // { + // // + // var result = GetExceptionActionResult(ex); + // return result; + // } + // } + // #endregion + // #endregion + // } } \ No newline at end of file