diff --git a/Providers/XCategoryProvider.cs b/Providers/XCategoryProvider.cs index 29b2c92..8de96d8 100644 --- a/Providers/XCategoryProvider.cs +++ b/Providers/XCategoryProvider.cs @@ -19,6 +19,7 @@ using xDataService.Extensions; using xPushService.Constants; using xPushService.Providers; using xDataService.Configuration; +using xDataService.Models; namespace xCategoryService.Providers { @@ -29,13 +30,15 @@ namespace xCategoryService.Providers private readonly XDataServiceConfiguration dataServiceConfiguration; private readonly IXCategoryTitleResourceProvider titleResourceProvider; private readonly IXCategoryDescriptionResourceProvider descriptionResourceProvider; + private readonly IXCategorySubCategoryReferenceProvider categorySubCategoryReferenceProvider; public XCategoryProvider( XAppConfiguration appConfiguration, IXCategoryServiceProvider provider, XDataServiceConfiguration dataServiceConfiguration, IXCategoryTitleResourceProvider titleResourceProvider, - IXCategoryDescriptionResourceProvider descriptionResourceProvider + IXCategoryDescriptionResourceProvider descriptionResourceProvider, + IXCategorySubCategoryReferenceProvider categorySubCategoryReferenceProvider ) : base( provider, permittedRoles: new string[] { } @@ -47,6 +50,7 @@ namespace xCategoryService.Providers this.titleResourceProvider = titleResourceProvider; this.dataServiceConfiguration = dataServiceConfiguration; this.descriptionResourceProvider = descriptionResourceProvider; + this.categorySubCategoryReferenceProvider = categorySubCategoryReferenceProvider; } // @@ -849,7 +853,7 @@ namespace xCategoryService.Providers // // Descriptions ... var updateDescriptions = result.Descriptions.Locales.Where( - l => resource.Descriptions.Locales.Any(r => + l => resource.Descriptions.Locales.Any(r => r.Value .Equals(l.Value, StringComparison.InvariantCultureIgnoreCase) && r.Language @@ -1179,5 +1183,261 @@ namespace xCategoryService.Providers return result; } #endregion + + // + #region SubCategory References ... + /// + /// Get Specified Indexed Reference for Specific Provided ID ... + /// + /// + /// + /// + /// + public async Task GetReference( + int providedForId, + int forIndex = 0, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .GetReference( + forIndex: forIndex, + providedForId: providedForId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Retrieve all Exists References of Specific Provided ID ... + /// + /// + /// + /// + public async Task> GetAllReferences( + int providedForId, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .GetAllReferences( + providedForId: providedForId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Extract all Referencing Models for Specified Key ... + /// + /// + /// + /// + public async Task>> GetAllReferencings( + int providedForId, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .GetAllReferencings( + providedForId: providedForId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Count References ... + /// + /// + /// + /// + public async Task CountReferences( + int providedForId, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .CountReferences( + providedForId: providedForId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Retrieve References of Specific Provided ID as Query ... + /// + /// + /// + /// + /// + public async Task> QueryReferences( + XQuery query, + int providedForId, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .QueryReferences( + query: query, + providedForId: providedForId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Add Reference a Model to Specific Provided ID ... + /// + /// + /// + /// + /// + /// + public async Task AddReference( + XCategoryDto model, + int providedForId, + string connectionId = null, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .AddReference( + model: model, + connectionId: connectionId, + providedForId: providedForId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Add Reference a Model to Specific XRefence ... + /// + /// + /// + /// + /// + /// + public async Task AddReference( + XCategoryDto model, + XReference reference, + string connectionId = null, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .AddReference( + model: model, + reference: reference, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Remove Reference a Model for Specific Provided ID ... + /// + /// + /// + /// + /// + /// + public async Task RemoveReference( + XCategoryDto model, + int providedForId, + string connectionId = null, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .RemoveReference( + model: model, + connectionId: connectionId, + providedForId: providedForId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Remove Reference a Model for Specific XRefence ... + /// + /// + /// + /// + /// + /// + public async Task RemoveReference( + XCategoryDto model, + XReference reference, + string connectionId = null, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .RemoveReference( + model: model, + reference: reference, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + + // + return result; + } + + /// + /// Remove All References to Specified Key ... + /// + /// + /// + /// + /// + public async Task RemoveReferences( + int providedForId, + string connectionId = null, + CancellationToken cancellationToken = default + ) + { + // + var result = await categorySubCategoryReferenceProvider + .RemoveReferences( + connectionId: connectionId, + providedForId: providedForId, + cancellationToken: cancellationToken + ); + + // + return result; + } + #endregion } } \ No newline at end of file