From e37bad59acbe59ea43d72e76a9b6bf8d22ce66f0 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 28 Jul 2026 21:31:42 +0330 Subject: [PATCH] Refactor Category Service ... - Add all HardCoded Strings in Constants ... - Apply Resolve Constant Replacement Side Affects ... - add Support for Service Main Provider ... --- .../Entities/XCategoryEntityConfiguration.cs | 3 +- .../XSubCategoryEntityConfiguration.cs | 3 +- Constants/XCategoryServiceConstants.cs | 29 + DI/XDIHelperExtension.cs | 19 +- Interfaces/{ => Entities}/IXCategorySeeder.cs | 2 +- .../{ => Entities}/IXSubCategorySeeder.cs | 2 +- Interfaces/IXCategoryProvider.cs | 1 + Interfaces/IXCategoryService.cs | 352 +++++++++++ Interfaces/IXSubCategoryProvider.cs | 1 + .../{ => Entities}/XCategorySeederBase.cs | 3 +- .../{ => Entities}/XSubCategorySeederBase.cs | 3 +- .../GraphQL/XCategoryGraphQLTypeHelper.cs | 5 +- .../GraphQL/XSubCategoryGraphQLTypeHelper.cs | 5 +- .../XCategoryDescriptionResourceProvider.cs | 5 +- Providers/XCategoryProvider.cs | 1 + Providers/XCategoryService.cs | 589 ++++++++++++++++++ Providers/XCategoryServiceSeeder.cs | 12 - Providers/XCategoryTitleResourceProvider.cs | 5 +- ...XSubCategoryDescriptionResourceProvider.cs | 5 +- Providers/XSubCategoryProvider.cs | 1 + .../XSubCategoryTitleResourceProvider.cs | 5 +- 21 files changed, 1013 insertions(+), 38 deletions(-) rename Interfaces/{ => Entities}/IXCategorySeeder.cs (76%) rename Interfaces/{ => Entities}/IXSubCategorySeeder.cs (77%) create mode 100644 Interfaces/IXCategoryService.cs rename Providers/{ => Entities}/XCategorySeederBase.cs (89%) rename Providers/{ => Entities}/XSubCategorySeederBase.cs (89%) create mode 100644 Providers/XCategoryService.cs delete mode 100644 Providers/XCategoryServiceSeeder.cs diff --git a/Configurations/Entities/XCategoryEntityConfiguration.cs b/Configurations/Entities/XCategoryEntityConfiguration.cs index 018f600..423a7cf 100644 --- a/Configurations/Entities/XCategoryEntityConfiguration.cs +++ b/Configurations/Entities/XCategoryEntityConfiguration.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; +using xCategoryService.Constants; using xCategoryService.Models.Entities; using xDataService.Providers; @@ -9,7 +10,7 @@ namespace xCategoryService.Configurations.Entities { public override void Configure(EntityTypeBuilder builder) { - builder.ToTable("Categories"); + builder.ToTable(XCategoryServiceConstants.XCategoryTable); } } } \ No newline at end of file diff --git a/Configurations/Entities/XSubCategoryEntityConfiguration.cs b/Configurations/Entities/XSubCategoryEntityConfiguration.cs index de3cb67..c5d874f 100644 --- a/Configurations/Entities/XSubCategoryEntityConfiguration.cs +++ b/Configurations/Entities/XSubCategoryEntityConfiguration.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; +using xCategoryService.Constants; using xCategoryService.Models.Entities; using xDataService.Providers; @@ -9,7 +10,7 @@ namespace xCategoryService.Configurations.Entities { public override void Configure(EntityTypeBuilder builder) { - builder.ToTable("SubCategories"); + builder.ToTable(XCategoryServiceConstants.XSubCategoryTable); } } } \ No newline at end of file diff --git a/Constants/XCategoryServiceConstants.cs b/Constants/XCategoryServiceConstants.cs index 2176ed8..22329b1 100644 --- a/Constants/XCategoryServiceConstants.cs +++ b/Constants/XCategoryServiceConstants.cs @@ -2,6 +2,35 @@ namespace xCategoryService.Constants { public struct XCategoryServiceConstants { + // + // Service Extensions Log Tag ... + public const string XCategoryServiceDILogTag = "XCategoryService"; + + // + // Table Mapping Identifiers ... + public const string XCategoryTable = "Categories"; + public const string XSubCategoryTable = "SubCategories"; + + // + // GraphQL Collection Mappings ... + public const string XCategorySingleName = "category"; + public const string XCategoryCollectionName = "categories"; + public const string XSubCategorySingleName = "subCategory"; + public const string XSubCategoryCollectionName = "subCategories"; + + // + // Hubs ... + public const string XCategoryDtoHub = "categoryDto"; + public const string XCategoryEntityHub = "categoryEntity"; + public const string XSubCategoryDtoHub = "subCategoryDto"; + public const string XSubCategoryEntityHub = "subCategoryEntity"; + + // + // Custome Constants ... public const string SubCategoryReference = "SubCat"; + public const string CategoryTitleResourceIdentifier = "CatT"; + public const string CategoryDescriptionResourceIdentifier = "CatD"; + public const string SubCategoryTitleResourceIdentifier = "SubCatT"; + public const string SubCategoryDescriptionResourceIdentifier = "SubCatD"; } } \ No newline at end of file diff --git a/DI/XDIHelperExtension.cs b/DI/XDIHelperExtension.cs index 4e36a5d..6b7ac49 100644 --- a/DI/XDIHelperExtension.cs +++ b/DI/XDIHelperExtension.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using xCategoryService.Configurations; +using xCategoryService.Constants; using xCategoryService.Helpers; using xCategoryService.Interfaces; using xCategoryService.Interfaces.Dtos; @@ -149,13 +150,13 @@ namespace xCategoryService.DI // // Category ... - pushHelper.AddHub("categoryDto"); - pushHelper.AddHub("categoryEntity"); + pushHelper.AddHub(XCategoryServiceConstants.XCategoryDtoHub); + pushHelper.AddHub(XCategoryServiceConstants.XCategoryEntityHub); // // SubCategory ... - pushHelper.AddHub("subCategoryDto"); - pushHelper.AddHub("subCategoryEntity"); + pushHelper.AddHub(XCategoryServiceConstants.XSubCategoryDtoHub); + pushHelper.AddHub(XCategoryServiceConstants.XSubCategoryEntityHub); // app.UseXPushService(pushHelper); @@ -295,7 +296,7 @@ namespace xCategoryService.DI /// /// a LogTag for Service ... /// - private static string XLogTag = "XCategoryService"; + private static string XLogTag = XCategoryServiceConstants.XCategoryServiceDILogTag; /// /// print a log in Console ... @@ -430,7 +431,7 @@ namespace xCategoryService.DI } // - #region Register Services ... + #region Register Services ... // #region Category ... // @@ -498,6 +499,12 @@ namespace xCategoryService.DI #endregion #endregion + // + // Register Service Main Provider ... + services.Add( + new ServiceDescriptor(typeof(IXCategoryService), typeof(XCategoryService), lifeTime) + ); + // Log("Service Regitration Succeed ..."); } diff --git a/Interfaces/IXCategorySeeder.cs b/Interfaces/Entities/IXCategorySeeder.cs similarity index 76% rename from Interfaces/IXCategorySeeder.cs rename to Interfaces/Entities/IXCategorySeeder.cs index d7f8abc..f36ffdd 100644 --- a/Interfaces/IXCategorySeeder.cs +++ b/Interfaces/Entities/IXCategorySeeder.cs @@ -1,7 +1,7 @@ using xCategoryService.Models.Entities; using xDataService.Interfaces; -namespace xCategoryService.Interfaces +namespace xCategoryService.Interfaces.Entities { public interface IXCategorySeeder : IXBaseDbSeeder { } diff --git a/Interfaces/IXSubCategorySeeder.cs b/Interfaces/Entities/IXSubCategorySeeder.cs similarity index 77% rename from Interfaces/IXSubCategorySeeder.cs rename to Interfaces/Entities/IXSubCategorySeeder.cs index eac06e8..9823d65 100644 --- a/Interfaces/IXSubCategorySeeder.cs +++ b/Interfaces/Entities/IXSubCategorySeeder.cs @@ -1,7 +1,7 @@ using xCategoryService.Models.Entities; using xDataService.Interfaces; -namespace xCategoryService.Interfaces +namespace xCategoryService.Interfaces.Entities { public interface IXSubCategorySeeder : IXBaseDbSeeder { } diff --git a/Interfaces/IXCategoryProvider.cs b/Interfaces/IXCategoryProvider.cs index 5162291..18c240e 100644 --- a/Interfaces/IXCategoryProvider.cs +++ b/Interfaces/IXCategoryProvider.cs @@ -146,6 +146,7 @@ namespace xCategoryService.Interfaces /// Find Many Resource ... /// /// + /// /// /// Task> FindManyResource( diff --git a/Interfaces/IXCategoryService.cs b/Interfaces/IXCategoryService.cs new file mode 100644 index 0000000..49d327e --- /dev/null +++ b/Interfaces/IXCategoryService.cs @@ -0,0 +1,352 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; +using xCategoryService.Models.Dtos; +using xIdentityModels.Models; +using xModels.Dtos; + +namespace xCategoryService.Interfaces +{ + /// + /// Completely Exported Service ... + /// + public interface IXCategoryService + { + // + #region Category Provider ... + /// + /// Check Has Specified Locale or not ... + /// + /// + /// + /// + /// + Task CategoryHasLocale( + int id, + string language, + CancellationToken cancellationToken = default + ); + + /// + /// Load an Item by all of it's Related Translations ... + /// + /// + /// + /// + Task GetCategoryResource( + int id, + CancellationToken cancellationToken = default + ); + + /// + /// Add Item for Specified Language ... + /// + /// + /// + /// + /// + /// + /// + Task AddCategory( + XCategoryDto item, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Add Item by It's Locales ... + /// + /// + /// + /// + /// + /// + Task AddCategoryResource( + XCategoryResourceDto item, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Remove Item for Specified Language ... + /// + /// + /// if null, Remove All + /// + /// + /// + /// + Task RemoveCategory( + int id, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Update an Item for Specified Language ... + /// + /// + /// + /// + /// + /// + /// + /// + Task UpdateCategory( + int id, + XCategoryDto item, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Refresh a Resource ... + /// + /// + /// + /// + /// + /// + Task RefreshCategory( + XCategoryResourceDto resource, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Get All Resources ... + /// + /// + /// + Task> GetAllCategoryResources( + CancellationToken cancellationToken = default + ); + + /// + /// Find One Resource ... + /// + /// + /// + /// + Task FindOneCategoryResource( + Expression> predicate = null, + CancellationToken cancellationToken = default + ); + + /// + /// Find Many Resource ... + /// + /// + /// + /// + /// + Task> FindManyCategoryResource( + Expression> predicate = null, + Func, IOrderedQueryable> orderBuilder = null, + CancellationToken cancellationToken = default + ); + + /// + /// Retrieve Resources by Query Pattern ... + /// + /// + /// + /// + /// + /// + Task> QueryCategoryResources( + XQuery query = null, + Expression> predicate = null, + Func, IOrderedQueryable> orderBuilder = null, + CancellationToken cancellationToken = default + ); + + /// + /// Get All Resources as Async Enumerable ... + /// + /// + /// + IAsyncEnumerable GetAllCategoryResourcesAsAsyncEnumerable( + CancellationToken cancellationToken = default + ); + #endregion + + // + #region SubCategory Provider ... + /// + /// Check Has Specified Locale or not ... + /// + /// + /// + /// + /// + Task SubCategoryHasLocale( + int id, + string language, + CancellationToken cancellationToken = default + ); + + /// + /// Load an Item by all of it's Related Translations ... + /// + /// + /// + /// + Task GetSubCategoryResource( + int id, + CancellationToken cancellationToken = default + ); + + /// + /// Add Item for Specified Language ... + /// + /// + /// + /// + /// + /// + /// + Task AddSubCategory( + XSubCategoryDto item, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Add Item by it's Locales and Reference ... + /// + /// + /// + /// + /// + /// + Task AddSubCategoryResource( + XSubCategoryResourceDto item, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Remove Item for Specified Language ... + /// + /// + /// if null, Remove All + /// + /// + /// + /// + Task RemoveSubCategory( + int id, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Update an Item for Specified Language ... + /// + /// + /// + /// + /// + /// + /// + /// + Task UpdateSubCategory( + int id, + XSubCategoryDto item, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Refresh a Resource ... + /// + /// + /// + /// + /// + /// + Task RefreshSubCategory( + XSubCategoryResourceDto resource, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ); + + /// + /// Get All Resources ... + /// + /// + /// + Task> GetAllSubCategoryResources( + CancellationToken cancellationToken = default + ); + + /// + /// Find One Resource ... + /// + /// + /// + /// + Task FindOneSubCategoryResource( + Expression> predicate = null, + CancellationToken cancellationToken = default + ); + + /// + /// Find Many Resource ... + /// + /// + /// + /// + /// + Task> FindManySubCategoryResource( + Expression> predicate = null, + Func, IOrderedQueryable> orderBuilder = null, + CancellationToken cancellationToken = default + ); + + /// + /// Retrieve Resources by Query Pattern ... + /// + /// + /// + /// + /// + /// + Task> QuerySubCategoryResources( + XQuery query = null, + Expression> predicate = null, + Func, IOrderedQueryable> orderBuilder = null, + CancellationToken cancellationToken = default + ); + + /// + /// Get All Resources as Async Enumerable ... + /// + /// + /// + IAsyncEnumerable GetAllSubCategoryResourcesAsAsyncEnumerable( + CancellationToken cancellationToken = default + ); + #endregion + } +} \ No newline at end of file diff --git a/Interfaces/IXSubCategoryProvider.cs b/Interfaces/IXSubCategoryProvider.cs index eba0784..32673f9 100644 --- a/Interfaces/IXSubCategoryProvider.cs +++ b/Interfaces/IXSubCategoryProvider.cs @@ -146,6 +146,7 @@ namespace xCategoryService.Interfaces /// Find Many Resource ... /// /// + /// /// /// Task> FindManyResource( diff --git a/Providers/XCategorySeederBase.cs b/Providers/Entities/XCategorySeederBase.cs similarity index 89% rename from Providers/XCategorySeederBase.cs rename to Providers/Entities/XCategorySeederBase.cs index 573caee..05415f6 100644 --- a/Providers/XCategorySeederBase.cs +++ b/Providers/Entities/XCategorySeederBase.cs @@ -1,10 +1,9 @@ -using xCategoryService.Interfaces; using xCategoryService.Interfaces.Entities; using xCategoryService.Models.Entities; using xDataService.Configuration; using xDataService.Providers; -namespace xCategoryService.Providers +namespace xCategoryService.Providers.Entities { public abstract class XCategorySeederBase : XBaseDbSeeder, IXCategorySeeder { diff --git a/Providers/XSubCategorySeederBase.cs b/Providers/Entities/XSubCategorySeederBase.cs similarity index 89% rename from Providers/XSubCategorySeederBase.cs rename to Providers/Entities/XSubCategorySeederBase.cs index 426340b..659b14e 100644 --- a/Providers/XSubCategorySeederBase.cs +++ b/Providers/Entities/XSubCategorySeederBase.cs @@ -1,10 +1,9 @@ -using xCategoryService.Interfaces; using xCategoryService.Interfaces.Entities; using xCategoryService.Models.Entities; using xDataService.Configuration; using xDataService.Providers; -namespace xCategoryService.Providers +namespace xCategoryService.Providers.Entities { public abstract class XSubCategorySeederBase : XBaseDbSeeder, IXSubCategorySeeder { diff --git a/Providers/GraphQL/XCategoryGraphQLTypeHelper.cs b/Providers/GraphQL/XCategoryGraphQLTypeHelper.cs index 23c6882..0a69488 100644 --- a/Providers/GraphQL/XCategoryGraphQLTypeHelper.cs +++ b/Providers/GraphQL/XCategoryGraphQLTypeHelper.cs @@ -1,3 +1,4 @@ +using xCategoryService.Constants; using xCategoryService.Interfaces.Entities; using xCategoryService.Models.Entities; using xDataService.Configuration; @@ -14,12 +15,12 @@ namespace xCategoryService.Providers.GraphQL public override string GetInQueryCollectionName() { - return "categories"; + return XCategoryServiceConstants.XCategoryCollectionName; } public override string GetInQuerySingleName() { - return "category"; + return XCategoryServiceConstants.XCategorySingleName; } } } \ No newline at end of file diff --git a/Providers/GraphQL/XSubCategoryGraphQLTypeHelper.cs b/Providers/GraphQL/XSubCategoryGraphQLTypeHelper.cs index cec88c3..d4e1caf 100644 --- a/Providers/GraphQL/XSubCategoryGraphQLTypeHelper.cs +++ b/Providers/GraphQL/XSubCategoryGraphQLTypeHelper.cs @@ -1,3 +1,4 @@ +using xCategoryService.Constants; using xCategoryService.Interfaces.Entities; using xCategoryService.Models.Entities; using xDataService.Configuration; @@ -14,12 +15,12 @@ namespace xCategoryService.Providers.GraphQL public override string GetInQueryCollectionName() { - return "subCategories"; + return XCategoryServiceConstants.XSubCategoryCollectionName; } public override string GetInQuerySingleName() { - return "subCategory"; + return XCategoryServiceConstants.XSubCategorySingleName; } } } \ No newline at end of file diff --git a/Providers/XCategoryDescriptionResourceProvider.cs b/Providers/XCategoryDescriptionResourceProvider.cs index f40c4fc..8bdd132 100644 --- a/Providers/XCategoryDescriptionResourceProvider.cs +++ b/Providers/XCategoryDescriptionResourceProvider.cs @@ -1,3 +1,4 @@ +using xCategoryService.Constants; using xCategoryService.Interfaces; using xStringService.Interfaces.Dtos; using xStringService.Providers; @@ -9,8 +10,8 @@ namespace xCategoryService.Providers public XCategoryDescriptionResourceProvider( IXStringServiceProvider stringProvider ) : base( - item: "CatD", - stringProvider + stringProvider: stringProvider, + item: XCategoryServiceConstants.CategoryDescriptionResourceIdentifier ) { } } diff --git a/Providers/XCategoryProvider.cs b/Providers/XCategoryProvider.cs index a19b939..bd131b1 100644 --- a/Providers/XCategoryProvider.cs +++ b/Providers/XCategoryProvider.cs @@ -1231,6 +1231,7 @@ namespace xCategoryService.Providers /// Find Many Resource ... /// /// + /// /// /// public async Task> FindManyResource( diff --git a/Providers/XCategoryService.cs b/Providers/XCategoryService.cs new file mode 100644 index 0000000..4b13c6a --- /dev/null +++ b/Providers/XCategoryService.cs @@ -0,0 +1,589 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Threading; +using System.Threading.Tasks; +using xCategoryService.Interfaces; +using xCategoryService.Models.Dtos; +using xIdentityModels.Models; +using xModels.Dtos; + +namespace xCategoryService.Providers +{ + /// + /// Completely Exported Service ... + /// + public class XCategoryService : IXCategoryService + { + private readonly IXCategoryProvider categoryProvider; + private readonly IXSubCategoryProvider subCategoryProvider; + + public XCategoryService( + IXCategoryProvider categoryProvider, + IXSubCategoryProvider subCategoryProvider + ) + { + this.categoryProvider = categoryProvider; + this.subCategoryProvider = subCategoryProvider; + } + + // + #region Category Provider ... + /// + /// Check Has Specified Locale or not ... + /// + /// + /// + /// + /// + public virtual async Task CategoryHasLocale( + int id, + string language, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .HasLocale( + id: id, + language: language, + cancellationToken: cancellationToken + ); + } + + /// + /// Load an Item by all of it's Related Translations ... + /// + /// + /// + /// + public virtual async Task GetCategoryResource( + int id, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .GetResource( + id: id, + cancellationToken: cancellationToken + ); + } + + /// + /// Add Item for Specified Language ... + /// + /// + /// + /// + /// + /// + /// + public virtual async Task AddCategory( + XCategoryDto item, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .Add( + item: item, + language: language, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Add Item by It's Locales ... + /// + /// + /// + /// + /// + /// + public virtual async Task AddCategoryResource( + XCategoryResourceDto item, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .AddResource( + item: item, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Remove Item for Specified Language ... + /// + /// + /// if null, Remove All + /// + /// + /// + /// + public virtual async Task RemoveCategory( + int id, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .Remove( + id: id, + language: language, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Update an Item for Specified Language ... + /// + /// + /// + /// + /// + /// + /// + /// + public virtual async Task UpdateCategory( + int id, + XCategoryDto item, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .Update( + id: id, + item: item, + language: language, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Refresh a Resource ... + /// + /// + /// + /// + /// + /// + public virtual async Task RefreshCategory( + XCategoryResourceDto resource, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .Refresh( + resource: resource, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Get All Resources ... + /// + /// + /// + public virtual async Task> GetAllCategoryResources( + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .GetAllResources( + cancellationToken: cancellationToken + ); + } + + /// + /// Find One Resource ... + /// + /// + /// + /// + public virtual async Task FindOneCategoryResource( + Expression> predicate = null, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .FindOneResource( + predicate: predicate, + cancellationToken: cancellationToken + ); + } + + /// + /// Find Many Resource ... + /// + /// + /// + /// + /// + public virtual async Task> FindManyCategoryResource( + Expression> predicate = null, + Func, IOrderedQueryable> orderBuilder = null, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .FindManyResource( + predicate: predicate, + orderBuilder: orderBuilder, + cancellationToken: cancellationToken + ); + } + + /// + /// Retrieve Resources by Query Pattern ... + /// + /// + /// + /// + /// + /// + public virtual async Task> QueryCategoryResources( + XQuery query = null, + Expression> predicate = null, + Func, IOrderedQueryable> orderBuilder = null, + CancellationToken cancellationToken = default + ) + { + // + return await categoryProvider + .QueryResources( + query: query, + predicate: predicate, + orderBuilder: orderBuilder, + cancellationToken: cancellationToken + ); + } + + /// + /// Get All Resources as Async Enumerable ... + /// + /// + /// + public virtual IAsyncEnumerable GetAllCategoryResourcesAsAsyncEnumerable( + CancellationToken cancellationToken = default + ) + { + // + return categoryProvider + .GetAllResourcesAsAsyncEnumerable( + cancellationToken: cancellationToken + ); + } + #endregion + + // + #region SubCategory Provider ... + /// + /// Check Has Specified Locale or not ... + /// + /// + /// + /// + /// + public virtual async Task SubCategoryHasLocale( + int id, + string language, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .HasLocale( + id: id, + language: language, + cancellationToken: cancellationToken + ); + } + + /// + /// Load an Item by all of it's Related Translations ... + /// + /// + /// + /// + public virtual async Task GetSubCategoryResource( + int id, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .GetResource( + id: id, + cancellationToken: cancellationToken + ); + } + + /// + /// Add Item for Specified Language ... + /// + /// + /// + /// + /// + /// + /// + public virtual async Task AddSubCategory( + XSubCategoryDto item, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .Add( + item: item, + language: language, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Add Item by it's Locales and Reference ... + /// + /// + /// + /// + /// + /// + public virtual async Task AddSubCategoryResource( + XSubCategoryResourceDto item, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .AddResource( + item: item, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Remove Item for Specified Language ... + /// + /// + /// if null, Remove All + /// + /// + /// + /// + public virtual async Task RemoveSubCategory( + int id, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .Remove( + id: id, + language: language, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Update an Item for Specified Language ... + /// + /// + /// + /// + /// + /// + /// + /// + public virtual async Task UpdateSubCategory( + int id, + XSubCategoryDto item, + string language = null, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .Update( + id: id, + item: item, + language: language, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Refresh a Resource ... + /// + /// + /// + /// + /// + /// + public virtual async Task RefreshSubCategory( + XSubCategoryResourceDto resource, + string connectionId = null, + XUserClaimsInfoDto userInfo = null, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .Refresh( + resource: resource, + userInfo: userInfo, + connectionId: connectionId, + cancellationToken: cancellationToken + ); + } + + /// + /// Get All Resources ... + /// + /// + /// + public virtual async Task> GetAllSubCategoryResources( + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .GetAllResources( + cancellationToken: cancellationToken + ); + } + + /// + /// Find One Resource ... + /// + /// + /// + /// + public virtual async Task FindOneSubCategoryResource( + Expression> predicate = null, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .FindOneResource( + predicate: predicate, + cancellationToken: cancellationToken + ); + } + + /// + /// Find Many Resource ... + /// + /// + /// + /// + /// + public virtual async Task> FindManySubCategoryResource( + Expression> predicate = null, + Func, IOrderedQueryable> orderBuilder = null, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .FindManyResource( + predicate: predicate, + orderBuilder: orderBuilder, + cancellationToken: cancellationToken + ); + } + + /// + /// Retrieve Resources by Query Pattern ... + /// + /// + /// + /// + /// + /// + public virtual async Task> QuerySubCategoryResources( + XQuery query = null, + Expression> predicate = null, + Func, IOrderedQueryable> orderBuilder = null, + CancellationToken cancellationToken = default + ) + { + // + return await subCategoryProvider + .QueryResources( + query: query, + predicate: predicate, + orderBuilder: orderBuilder, + cancellationToken: cancellationToken + ); + } + + /// + /// Get All Resources as Async Enumerable ... + /// + /// + /// + public virtual IAsyncEnumerable GetAllSubCategoryResourcesAsAsyncEnumerable( + CancellationToken cancellationToken = default + ) + { + // + return subCategoryProvider + .GetAllResourcesAsAsyncEnumerable( + cancellationToken: cancellationToken + ); + } + #endregion + } +} \ No newline at end of file diff --git a/Providers/XCategoryServiceSeeder.cs b/Providers/XCategoryServiceSeeder.cs deleted file mode 100644 index 5762886..0000000 --- a/Providers/XCategoryServiceSeeder.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace xCategoryService.Providers -{ - public class XCategoryServiceSeeder - { - - } -} \ No newline at end of file diff --git a/Providers/XCategoryTitleResourceProvider.cs b/Providers/XCategoryTitleResourceProvider.cs index 2a86e2c..58b8fc4 100644 --- a/Providers/XCategoryTitleResourceProvider.cs +++ b/Providers/XCategoryTitleResourceProvider.cs @@ -1,3 +1,4 @@ +using xCategoryService.Constants; using xCategoryService.Interfaces; using xStringService.Interfaces.Dtos; using xStringService.Providers; @@ -9,8 +10,8 @@ namespace xCategoryService.Providers public XCategoryTitleResourceProvider( IXStringServiceProvider stringProvider ) : base( - item: "CatT", - stringProvider + stringProvider: stringProvider, + item: XCategoryServiceConstants.CategoryTitleResourceIdentifier ) { } } diff --git a/Providers/XSubCategoryDescriptionResourceProvider.cs b/Providers/XSubCategoryDescriptionResourceProvider.cs index 9ac27da..18bf60e 100644 --- a/Providers/XSubCategoryDescriptionResourceProvider.cs +++ b/Providers/XSubCategoryDescriptionResourceProvider.cs @@ -1,3 +1,4 @@ +using xCategoryService.Constants; using xCategoryService.Interfaces; using xStringService.Interfaces.Dtos; using xStringService.Providers; @@ -9,8 +10,8 @@ namespace xCategoryService.Providers public XSubCategoryDescriptionResourceProvider( IXStringServiceProvider stringProvider ) : base( - item: "SubCatD", - stringProvider + stringProvider: stringProvider, + item: XCategoryServiceConstants.SubCategoryDescriptionResourceIdentifier ) { } } diff --git a/Providers/XSubCategoryProvider.cs b/Providers/XSubCategoryProvider.cs index 2f9039c..2456c90 100644 --- a/Providers/XSubCategoryProvider.cs +++ b/Providers/XSubCategoryProvider.cs @@ -1322,6 +1322,7 @@ namespace xCategoryService.Providers /// Find Many Resource ... /// /// + /// /// /// public async Task> FindManyResource( diff --git a/Providers/XSubCategoryTitleResourceProvider.cs b/Providers/XSubCategoryTitleResourceProvider.cs index 948a4b9..00f3925 100644 --- a/Providers/XSubCategoryTitleResourceProvider.cs +++ b/Providers/XSubCategoryTitleResourceProvider.cs @@ -1,3 +1,4 @@ +using xCategoryService.Constants; using xCategoryService.Interfaces; using xStringService.Interfaces.Dtos; using xStringService.Providers; @@ -9,8 +10,8 @@ namespace xCategoryService.Providers public XSubCategoryTitleResourceProvider( IXStringServiceProvider stringProvider ) : base( - item: "SubCatT", - stringProvider + stringProvider: stringProvider, + item: XCategoryServiceConstants.SubCategoryTitleResourceIdentifier ) { } }