From a9c2f63b440a0561b2f9cbc756160876fe6d0c6e Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 31 May 2026 00:37:05 +0330 Subject: [PATCH] Complete SubCategory Data Models and Implementations ... --- .../Entities/XSubCategoryConfiguration.cs | 15 + .../XSubCategoryRepositoryControllerBase.cs | 33 +++ ...ategoryRepositoryProviderControllerBase.cs | 37 +++ .../XSubCategoryServiceControllerBase.cs | 34 +++ ...ubCategoryServiceProviderControllerBase.cs | 38 +++ DI/XDIHelperExtension.cs | 227 ++++++++++++++ Helpers/XCategoryServiceHelper.cs | 279 ++++++++++++++++++ Interfaces/Dtos/IXSubCategoryDtoHub.cs | 9 + .../Dtos/IXSubCategoryRepositoryService.cs | 9 + .../Dtos/IXSubCategoryServiceProvider.cs | 10 + Interfaces/Entities/IXSubCategoryEntityHub.cs | 8 + .../IXSubCategoryGraphQLTypeHelper.cs | 8 + .../Entities/IXSubCategoryKeyGenerator.cs | 8 + .../Entities/IXSubCategoryRepository.cs | 8 + .../Entities/IXSubCategoryRepositoryEvents.cs | 8 + .../IXSubCategoryRepositoryProvider.cs | 9 + ...XSubCategoryDescriptionResourceProvider.cs | 7 + Interfaces/IXSubCategorySeeder.cs | 8 + Models/Dtos/XSubCategoryDto.cs | 28 ++ Providers/Dtos/XSubCategoryDtoHub.cs | 16 + .../Dtos/XSubCategoryRepositoryService.cs | 22 ++ Providers/Dtos/XSubCategoryServiceProvider.cs | 26 ++ .../Entities/XSubCategoryEFRepository.cs | 26 ++ Providers/Entities/XSubCategoryEntityHub.cs | 15 + .../XSubCategoryInMemoryRepository.cs | 21 ++ .../Entities/XSubCategoryKeyGenerator.cs | 9 + .../Entities/XSubCategoryMongoRepository.cs | 25 ++ .../Entities/XSubCategoryRepositoryEvents.cs | 9 + .../XSubCategoryRepositoryProvider.cs | 25 ++ .../GraphQL/XSubCategoryGraphQLTypeHelper.cs | 25 ++ Providers/GraphQL/XSubCategoryGraphQuery.cs | 22 ++ Providers/GraphQL/XSubCategoryGraphSchema.cs | 14 + Providers/GraphQL/XSubCategoryGraphType.cs | 15 + ...XSubCategoryDescriptionResourceProvider.cs | 18 ++ Providers/XSubCategoryEntityRegisterar.cs | 27 ++ Providers/XSubCategorySeederBase.cs | 24 ++ 36 files changed, 1122 insertions(+) create mode 100644 Configurations/Entities/XSubCategoryConfiguration.cs create mode 100644 Controllers/XSubCategoryRepositoryControllerBase.cs create mode 100644 Controllers/XSubCategoryRepositoryProviderControllerBase.cs create mode 100644 Controllers/XSubCategoryServiceControllerBase.cs create mode 100644 Controllers/XSubCategoryServiceProviderControllerBase.cs create mode 100644 DI/XDIHelperExtension.cs create mode 100644 Helpers/XCategoryServiceHelper.cs create mode 100644 Interfaces/Dtos/IXSubCategoryDtoHub.cs create mode 100644 Interfaces/Dtos/IXSubCategoryRepositoryService.cs create mode 100644 Interfaces/Dtos/IXSubCategoryServiceProvider.cs create mode 100644 Interfaces/Entities/IXSubCategoryEntityHub.cs create mode 100644 Interfaces/Entities/IXSubCategoryGraphQLTypeHelper.cs create mode 100644 Interfaces/Entities/IXSubCategoryKeyGenerator.cs create mode 100644 Interfaces/Entities/IXSubCategoryRepository.cs create mode 100644 Interfaces/Entities/IXSubCategoryRepositoryEvents.cs create mode 100644 Interfaces/Entities/IXSubCategoryRepositoryProvider.cs create mode 100644 Interfaces/IXSubCategoryDescriptionResourceProvider.cs create mode 100644 Interfaces/IXSubCategorySeeder.cs create mode 100644 Models/Dtos/XSubCategoryDto.cs create mode 100644 Providers/Dtos/XSubCategoryDtoHub.cs create mode 100644 Providers/Dtos/XSubCategoryRepositoryService.cs create mode 100644 Providers/Dtos/XSubCategoryServiceProvider.cs create mode 100644 Providers/Entities/XSubCategoryEFRepository.cs create mode 100644 Providers/Entities/XSubCategoryEntityHub.cs create mode 100644 Providers/Entities/XSubCategoryInMemoryRepository.cs create mode 100644 Providers/Entities/XSubCategoryKeyGenerator.cs create mode 100644 Providers/Entities/XSubCategoryMongoRepository.cs create mode 100644 Providers/Entities/XSubCategoryRepositoryEvents.cs create mode 100644 Providers/Entities/XSubCategoryRepositoryProvider.cs create mode 100644 Providers/GraphQL/XSubCategoryGraphQLTypeHelper.cs create mode 100644 Providers/GraphQL/XSubCategoryGraphQuery.cs create mode 100644 Providers/GraphQL/XSubCategoryGraphSchema.cs create mode 100644 Providers/GraphQL/XSubCategoryGraphType.cs create mode 100644 Providers/XSubCategoryDescriptionResourceProvider.cs create mode 100644 Providers/XSubCategoryEntityRegisterar.cs create mode 100644 Providers/XSubCategorySeederBase.cs diff --git a/Configurations/Entities/XSubCategoryConfiguration.cs b/Configurations/Entities/XSubCategoryConfiguration.cs new file mode 100644 index 0000000..c505c4d --- /dev/null +++ b/Configurations/Entities/XSubCategoryConfiguration.cs @@ -0,0 +1,15 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using xCategoryService.Models.Entities; +using xDataService.Providers; + +namespace xCategoryService.Configurations.Entities +{ + public class XSubCategoryConfiguration : XBaseEntityTypeConfiguration + { + public override void Configure(EntityTypeBuilder builder) + { + builder.ToTable("SubCategories"); + } + } +} \ No newline at end of file diff --git a/Controllers/XSubCategoryRepositoryControllerBase.cs b/Controllers/XSubCategoryRepositoryControllerBase.cs new file mode 100644 index 0000000..7ff384c --- /dev/null +++ b/Controllers/XSubCategoryRepositoryControllerBase.cs @@ -0,0 +1,33 @@ +using System; +using System.Linq; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.Extensions.Logging; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xCommons.Configurations; +using xCommons.Providers; +using xDataService.Controllers; +using xDataService.Interfaces; + +namespace xCategoryService.Controllers +{ + public abstract class XSubCategoryRepositoryControllerBase : XBaseRepositoryController, IXBaseRepositoryController + { + protected XSubCategoryRepositoryControllerBase( + ILogger logger, + XAppConfiguration appConfiguration, + XValidationProvider validationProvider, + IXSubCategoryRepository repository, + Func, IOrderedQueryable> defaultOrderBuilder = null, + Func, IIncludableQueryable> defaultIncludeBuilder = null + ) : base( + logger, + appConfiguration, + validationProvider, + repository, + defaultOrderBuilder, + defaultIncludeBuilder + ) + { } + } +} \ No newline at end of file diff --git a/Controllers/XSubCategoryRepositoryProviderControllerBase.cs b/Controllers/XSubCategoryRepositoryProviderControllerBase.cs new file mode 100644 index 0000000..18aacbd --- /dev/null +++ b/Controllers/XSubCategoryRepositoryProviderControllerBase.cs @@ -0,0 +1,37 @@ +using System; +using System.Linq; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.Extensions.Logging; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xCategoryService.Providers.Entities; +using xCommons.Configurations; +using xCommons.Providers; +using xIdentityService.Interfaces; +using xPushService.Controllers; +using xPushService.Interfaces; + +namespace xCategoryService.Controllers +{ + public abstract class XSubCategoryRepositoryProviderControllerBase : XBaseRepositoryProviderController, IXBaseRepositoryProviderController + { + protected XSubCategoryRepositoryProviderControllerBase( + ILogger logger, + XAppConfiguration appConfiguration, + IXIdentityProvider identityProvider, + XValidationProvider validationProvider, + IXSubCategoryRepositoryProvider provider, + Func, IOrderedQueryable> defaultOrderBuilder = null, + Func, IIncludableQueryable> defaultIncludeBuilder = null + ) : base( + logger, + appConfiguration, + identityProvider, + validationProvider, + provider, + defaultOrderBuilder, + defaultIncludeBuilder + ) + { } + } +} \ No newline at end of file diff --git a/Controllers/XSubCategoryServiceControllerBase.cs b/Controllers/XSubCategoryServiceControllerBase.cs new file mode 100644 index 0000000..fd96b2e --- /dev/null +++ b/Controllers/XSubCategoryServiceControllerBase.cs @@ -0,0 +1,34 @@ +using System; +using System.Linq; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.Extensions.Logging; +using xCategoryService.Interfaces.Dtos; +using xCategoryService.Models.Dtos; +using xCategoryService.Models.Entities; +using xCommons.Configurations; +using xCommons.Providers; +using xDataService.Controllers; +using xDataService.Interfaces; + +namespace xCategoryService.Controllers +{ + public abstract class XSubCategoryServiceControllerBase : XBaseServiceController, IXBaseServiceController + { + protected XSubCategoryServiceControllerBase( + ILogger logger, + XAppConfiguration appConfiguration, + XValidationProvider validationProvider, + IXSubCategoryRepositoryService repositoryService, + Func, IOrderedQueryable> defaultOrderBuilder = null, + Func, IIncludableQueryable> defaultIncludeBuilder = null + ) : base( + logger, + appConfiguration, + validationProvider, + repositoryService, + defaultOrderBuilder, + defaultIncludeBuilder + ) + { } + } +} \ No newline at end of file diff --git a/Controllers/XSubCategoryServiceProviderControllerBase.cs b/Controllers/XSubCategoryServiceProviderControllerBase.cs new file mode 100644 index 0000000..04ef2a2 --- /dev/null +++ b/Controllers/XSubCategoryServiceProviderControllerBase.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.Extensions.Logging; +using xCategoryService.Interfaces.Dtos; +using xCategoryService.Models.Dtos; +using xCategoryService.Models.Entities; +using xCategoryService.Providers.Dtos; +using xCommons.Configurations; +using xCommons.Providers; +using xIdentityService.Interfaces; +using xPushService.Controllers; +using xPushService.Interfaces; + +namespace xCategoryService.Controllers +{ + public abstract class XSubCategoryServiceProviderControllerBase : XBaseServiceProviderController, IXBaseServiceProviderController + { + protected XSubCategoryServiceProviderControllerBase( + ILogger logger, + XAppConfiguration appConfiguration, + IXIdentityProvider identityProvider, + XValidationProvider validationProvider, + IXSubCategoryServiceProvider provider, + Func, IOrderedQueryable> defaultOrderBuilder = null, + Func, IIncludableQueryable> defaultIncludeBuilder = null + ) : base( + logger, + appConfiguration, + identityProvider, + validationProvider, + provider, + defaultOrderBuilder, + defaultIncludeBuilder + ) + { } + } +} \ No newline at end of file diff --git a/DI/XDIHelperExtension.cs b/DI/XDIHelperExtension.cs new file mode 100644 index 0000000..bd535aa --- /dev/null +++ b/DI/XDIHelperExtension.cs @@ -0,0 +1,227 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using xCategoryService.Helpers; +using xCategoryService.Interfaces.Dtos; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Providers.Dtos; +using xCategoryService.Providers.Entities; +using xCommons.Extensions; +using xCommons.Helpers; +using xDataService.Constants; +using xDataService.Db; +using xDataService.DI; +using xDataService.Models; +using xExceptions.Constants; +using xPushService.DI; +using xPushService.Helpers; + +namespace xCategoryService.DI +{ + public static class XDIHelperExtension + { + /// + /// Register Service ... + /// + /// + /// + /// + public static void AddXCategoryService( + this IServiceCollection services, + XRepositoryType repositoryType, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) + { + AddCategoryService( + contextType: null, + services: services, + lifeTime: lifeTime, + repositoryType: repositoryType + ); + } + + /// + /// Register Service ... + /// + /// + /// + /// + /// + public static void AddXCategoryService( + this IServiceCollection services, + XRepositoryType repositoryType, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) + where TContext : XDbContext + { + AddCategoryService( + services: services, + lifeTime: lifeTime, + contextType: typeof(TContext), + repositoryType: repositoryType + ); + } + + /// + /// Use XSubCategoryService Middleware ... + /// + /// + /// + public static void UseXCategoryService( + this IApplicationBuilder app, + bool isDevelopmentEnvironment = false + ) + { + // + #region Using XSubCategory Hubs ... + // + var pushHelper = new XPushServiceHelper(); + + // + pushHelper.AddHub("tagDto"); + pushHelper.AddHub("tagEntity"); + + // + app.UseXPushService(pushHelper); + #endregion + + // + // Using XSubCategory Repository Descriptor ... + if (!subCategoryescriptor.IsNull()) + { + // + app.UseXRepository( + descriptor: subCategoryescriptor, + isDevelopmentEnvironment: isDevelopmentEnvironment + ); + } + } + + // + #region Private ... + private static XRepositoryDescriptor categoryDescriptor = null; + private static XRepositoryDescriptor subCategoryescriptor = null; + + /// + /// a LogTag for Service ... + /// + private static string XLogTag = "XCategoryService"; + + /// + /// print a log in Console ... + /// + /// + private static void Log(string message) + { + Console.WriteLine($"{XLogTag} => {message}"); + } + + /// + /// Register Service ... + /// + /// + /// + /// + /// + private static void AddCategoryService( + IServiceCollection services, + XRepositoryType repositoryType, + Type contextType = null, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) + { + // + var exception = XException.InvalidArgs.ToException(); ; + + // + // Services ... + var isServicesExists = !services.IsNull(); + if (!isServicesExists) + { + // + Log("Service Registration failed, services not provided ..."); + throw exception; + } + + // + // Lifetime ... + var isLifetimeExists = !lifeTime.IsNull(); + if (!isLifetimeExists) + { + // + Log("Service Registration failed, lifetime not provided ..."); + throw exception; + } + + // + // Validate Repository Type ... + var isRepositoryTypeValid = + (repositoryType == XRepositoryType.EF && + !contextType.IsNull()) || + ((repositoryType == XRepositoryType.Mongo || + repositoryType == XRepositoryType.InMemory) && + contextType.IsNull()); + if (!isRepositoryTypeValid) + { + // + Log("Service Registration failed, Invalid Repository Type and Context Type ..."); + throw exception; + } + + // + // Maske Instance of Repository Descriptor + // Based on Provided Type ... + switch (repositoryType) + { + // + case XRepositoryType.EF: + // + subCategoryescriptor = typeof(XCategoryServiceHelper) + .InvokeGenericMethod( + methodName: "GetXSubCategoryEFRepositoryDescriptor", + runtimeType: contextType, + args: null + ); + break; + + // + case XRepositoryType.Mongo: + subCategoryescriptor = XCategoryServiceHelper.GetXSubCategoryMongoRepositoryDescriptor(); + break; + + // + case XRepositoryType.InMemory: + subCategoryescriptor = XCategoryServiceHelper.GetXSubCategoryInMemoryRepositoryDescriptor(); + break; + } + + // + // Register XSubCategory Repository Descriptor ... + services.AddXRepository( + lifeTime: lifeTime, + descriptor: subCategoryescriptor + ); + + // + // Register Dto Services ... + services.Add( + new ServiceDescriptor(typeof(IXSubCategoryServiceProvider), typeof(XSubCategoryServiceProvider), lifeTime) + ); + services.Add( + new ServiceDescriptor(typeof(IXSubCategoryRepositoryService), typeof(XSubCategoryRepositoryService), lifeTime) + ); + services.Add( + new ServiceDescriptor(typeof(IXSubCategoryRepositoryProvider), typeof(XSubCategoryRepositoryProvider), lifeTime) + ); + + // + // services.Add( + // new ServiceDescriptor(typeof(IXSubCategoryProvider), typeof(XSubCategoryProvider), lifeTime) + // ); + + // + Log("Service Regitration Succeed ..."); + } + #endregion + } +} \ No newline at end of file diff --git a/Helpers/XCategoryServiceHelper.cs b/Helpers/XCategoryServiceHelper.cs new file mode 100644 index 0000000..5570d50 --- /dev/null +++ b/Helpers/XCategoryServiceHelper.cs @@ -0,0 +1,279 @@ +using GraphQL.Types; +using xCategoryService.Interfaces; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xCategoryService.Providers.Entities; +using xCategoryService.Providers.GraphQL; +using xDataService.Db; +using xDataService.Models; +using xDataService.Providers; + +namespace xCategoryService.Helpers +{ + public static class XCategoryServiceHelper + { + // + #region EF Repository Descriptor Provider(s) ... + public static XEFRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryEFRepository, + TContext + > GetXSubCategoryEFRepositoryDescriptor() + where TContext : XDbContext + { + // + var result = new XEFRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryEFRepository, + TContext + >(); + + // + return result; + } + + public static XEFRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryEFRepository, + TContext, + IXSubCategorySeeder, + TSeederImplementation + > GetXSubCategoryEFRepositoryDescriptor() + where TContext : XDbContext + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XEFRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryEFRepository, + TContext, + IXSubCategorySeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + + // + #region Mongo Repository Descriptor Provider(s) ... + public static XMongoRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryMongoRepository + > GetXSubCategoryMongoRepositoryDescriptor() + { + // + var result = new XMongoRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryMongoRepository + >(); + + // + return result; + } + + public static XMongoRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryMongoRepository, + IXSubCategorySeeder, + TSeederImplementation + > GetXSubCategoryMongoRepositoryDescriptor() + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XMongoRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryMongoRepository, + IXSubCategorySeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + + // + #region InMemory Repository Descriptor Provider(s) ... + public static XInMemoryRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryInMemoryRepository + > GetXSubCategoryInMemoryRepositoryDescriptor() + { + // + var result = new XInMemoryRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryInMemoryRepository + >(); + + // + return result; + } + + public static XInMemoryRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryInMemoryRepository, + IXSubCategorySeeder, + TSeederImplementation + > GetXSubCategoryInMemoryRepositoryDescriptor() + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XInMemoryRepositoryDescriptor< + XSubCategory, + int, + IXSubCategoryKeyGenerator, + XSubCategoryKeyGenerator, + IXSubCategoryRepositoryEvents, + XSubCategoryRepositoryEvents, + XSubCategoryGraphType, + IntGraphType, + XSubCategoryGraphQuery, + IXSubCategoryGraphQLTypeHelper, + XSubCategoryGraphQLTypeHelper, + XSubCategoryGraphSchema, + IXSubCategoryRepository, + XSubCategoryInMemoryRepository, + IXSubCategorySeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + } +} \ No newline at end of file diff --git a/Interfaces/Dtos/IXSubCategoryDtoHub.cs b/Interfaces/Dtos/IXSubCategoryDtoHub.cs new file mode 100644 index 0000000..dda7080 --- /dev/null +++ b/Interfaces/Dtos/IXSubCategoryDtoHub.cs @@ -0,0 +1,9 @@ +using xCategoryService.Models.Dtos; +using xCategoryService.Models.Entities; +using xPushService.Interfaces; + +namespace xCategoryService.Interfaces.Dtos +{ + public interface IXSubCategoryDtoHub : IXBaseDtoHub + { } +} \ No newline at end of file diff --git a/Interfaces/Dtos/IXSubCategoryRepositoryService.cs b/Interfaces/Dtos/IXSubCategoryRepositoryService.cs new file mode 100644 index 0000000..1906b60 --- /dev/null +++ b/Interfaces/Dtos/IXSubCategoryRepositoryService.cs @@ -0,0 +1,9 @@ +using xCategoryService.Models.Dtos; +using xCategoryService.Models.Entities; +using xDataService.Interfaces; + +namespace xCategoryService.Interfaces.Dtos +{ + public interface IXSubCategoryRepositoryService : IXBaseRepositoryService + { } +} \ No newline at end of file diff --git a/Interfaces/Dtos/IXSubCategoryServiceProvider.cs b/Interfaces/Dtos/IXSubCategoryServiceProvider.cs new file mode 100644 index 0000000..a64406e --- /dev/null +++ b/Interfaces/Dtos/IXSubCategoryServiceProvider.cs @@ -0,0 +1,10 @@ +using xCategoryService.Models.Dtos; +using xCategoryService.Models.Entities; +using xCategoryService.Providers.Dtos; +using xPushService.Interfaces; + +namespace xCategoryService.Interfaces.Dtos +{ + public interface IXSubCategoryServiceProvider : IXBaseDtoProvider + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXSubCategoryEntityHub.cs b/Interfaces/Entities/IXSubCategoryEntityHub.cs new file mode 100644 index 0000000..88d5838 --- /dev/null +++ b/Interfaces/Entities/IXSubCategoryEntityHub.cs @@ -0,0 +1,8 @@ +using xCategoryService.Models.Entities; +using xPushService.Interfaces; + +namespace xCategoryService.Interfaces.Entities +{ + public interface IXSubCategoryEntityHub : IXBaseEntityHub + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXSubCategoryGraphQLTypeHelper.cs b/Interfaces/Entities/IXSubCategoryGraphQLTypeHelper.cs new file mode 100644 index 0000000..855d4c0 --- /dev/null +++ b/Interfaces/Entities/IXSubCategoryGraphQLTypeHelper.cs @@ -0,0 +1,8 @@ +using xCategoryService.Models.Entities; +using xDataService.Interfaces; + +namespace xCategoryService.Interfaces.Entities +{ + public interface IXSubCategoryGraphQLTypeHelper : IXBaseGraphQLTypeHelper + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXSubCategoryKeyGenerator.cs b/Interfaces/Entities/IXSubCategoryKeyGenerator.cs new file mode 100644 index 0000000..b03484f --- /dev/null +++ b/Interfaces/Entities/IXSubCategoryKeyGenerator.cs @@ -0,0 +1,8 @@ +using xCategoryService.Models.Entities; +using xDataService.Interfaces; + +namespace xCategoryService.Interfaces.Entities +{ + public interface IXSubCategoryKeyGenerator : IXKeyGenerator + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXSubCategoryRepository.cs b/Interfaces/Entities/IXSubCategoryRepository.cs new file mode 100644 index 0000000..998b1a7 --- /dev/null +++ b/Interfaces/Entities/IXSubCategoryRepository.cs @@ -0,0 +1,8 @@ +using xCategoryService.Models.Entities; +using xDataService.Interfaces; + +namespace xCategoryService.Interfaces.Entities +{ + public interface IXSubCategoryRepository : IXBaseRepository + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXSubCategoryRepositoryEvents.cs b/Interfaces/Entities/IXSubCategoryRepositoryEvents.cs new file mode 100644 index 0000000..e2385ac --- /dev/null +++ b/Interfaces/Entities/IXSubCategoryRepositoryEvents.cs @@ -0,0 +1,8 @@ +using xCategoryService.Models.Entities; +using xDataService.Interfaces; + +namespace xCategoryService.Interfaces.Entities +{ + public interface IXSubCategoryRepositoryEvents : IXBaseRepositoryEvents + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXSubCategoryRepositoryProvider.cs b/Interfaces/Entities/IXSubCategoryRepositoryProvider.cs new file mode 100644 index 0000000..67b647e --- /dev/null +++ b/Interfaces/Entities/IXSubCategoryRepositoryProvider.cs @@ -0,0 +1,9 @@ +using xCategoryService.Models.Entities; +using xCategoryService.Providers.Entities; +using xPushService.Interfaces; + +namespace xCategoryService.Interfaces.Entities +{ + public interface IXSubCategoryRepositoryProvider : IXBaseEntityProvider + { } +} \ No newline at end of file diff --git a/Interfaces/IXSubCategoryDescriptionResourceProvider.cs b/Interfaces/IXSubCategoryDescriptionResourceProvider.cs new file mode 100644 index 0000000..081f17e --- /dev/null +++ b/Interfaces/IXSubCategoryDescriptionResourceProvider.cs @@ -0,0 +1,7 @@ +using xStringService.Interfaces; + +namespace xCategoryService.Interfaces +{ + public interface IXSubCategoryDescriptionResourceProvider : IXItemResourceProvider + { } +} \ No newline at end of file diff --git a/Interfaces/IXSubCategorySeeder.cs b/Interfaces/IXSubCategorySeeder.cs new file mode 100644 index 0000000..eac06e8 --- /dev/null +++ b/Interfaces/IXSubCategorySeeder.cs @@ -0,0 +1,8 @@ +using xCategoryService.Models.Entities; +using xDataService.Interfaces; + +namespace xCategoryService.Interfaces +{ + public interface IXSubCategorySeeder : IXBaseDbSeeder + { } +} \ No newline at end of file diff --git a/Models/Dtos/XSubCategoryDto.cs b/Models/Dtos/XSubCategoryDto.cs new file mode 100644 index 0000000..9425307 --- /dev/null +++ b/Models/Dtos/XSubCategoryDto.cs @@ -0,0 +1,28 @@ +using xModels.Base; + +namespace xCategoryService.Models.Dtos +{ + public class XSubCategoryDto : XBaseIntIDEntityDto + { + /// + /// Title of SubCategory ... + /// this is a Resource Title ... + /// + /// + public string Title { get; set; } + + /// + /// Description of SubCategory ... + /// this is a Resource Title ... + /// + /// + public string Description { get; set; } + + /// + /// References List String Representation ... + /// each SubCategory Referenced to Category ID which List here ... + /// + /// + public string References { get; set; } + } +} \ No newline at end of file diff --git a/Providers/Dtos/XSubCategoryDtoHub.cs b/Providers/Dtos/XSubCategoryDtoHub.cs new file mode 100644 index 0000000..2ce0828 --- /dev/null +++ b/Providers/Dtos/XSubCategoryDtoHub.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.Logging; +using xCategoryService.Interfaces.Dtos; +using xCategoryService.Models.Dtos; +using xCategoryService.Models.Entities; +using xPushService.Base; + +namespace xCategoryService.Providers.Dtos +{ + public class XSubCategoryDtoHub : XBaseDtoHub, IXSubCategoryDtoHub + { + public XSubCategoryDtoHub( + ILogger logger + ) : base(logger) + { } + } +} \ No newline at end of file diff --git a/Providers/Dtos/XSubCategoryRepositoryService.cs b/Providers/Dtos/XSubCategoryRepositoryService.cs new file mode 100644 index 0000000..c2ed1a9 --- /dev/null +++ b/Providers/Dtos/XSubCategoryRepositoryService.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using AutoMapper; +using xCategoryService.Interfaces.Dtos; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Dtos; +using xCategoryService.Models.Entities; +using xDataService.Providers; + +namespace xCategoryService.Providers.Dtos +{ + public class XSubCategoryRepositoryService : XBaseRepositoryService, IXSubCategoryRepositoryService + { + public XSubCategoryRepositoryService( + IXSubCategoryRepository repository, + IEnumerable mapperProfiles = null + ) : base( + repository, + mapperProfiles + ) + { } + } +} \ No newline at end of file diff --git a/Providers/Dtos/XSubCategoryServiceProvider.cs b/Providers/Dtos/XSubCategoryServiceProvider.cs new file mode 100644 index 0000000..39d99ac --- /dev/null +++ b/Providers/Dtos/XSubCategoryServiceProvider.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.SignalR; +using xCategoryService.Interfaces.Dtos; +using xCategoryService.Models.Dtos; +using xCategoryService.Models.Entities; +using xDataService.Configuration; +using xIdentityService.Interfaces; +using xPushService.Base; + +namespace xCategoryService.Providers.Dtos +{ + public class XSubCategoryServiceProvider : XBaseDtoProvider, IXSubCategoryServiceProvider + { + public XSubCategoryServiceProvider( + IHubContext hub, + XDataServiceConfiguration dataConfiguration, + IXSubCategoryRepositoryService service, + IXIdentityProvider identityProvider = null + ) : base( + hub, + dataConfiguration, + service, + identityProvider + ) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XSubCategoryEFRepository.cs b/Providers/Entities/XSubCategoryEFRepository.cs new file mode 100644 index 0000000..e36d182 --- /dev/null +++ b/Providers/Entities/XSubCategoryEFRepository.cs @@ -0,0 +1,26 @@ +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Configuration; +using xDataService.Db; +using xDataService.Interfaces; +using xDataService.Providers; + +namespace xCategoryService.Providers.Entities +{ + public class XSubCategoryEFRepository : XBaseEFRepository, IXSubCategoryRepository + where TContext : XDbContext + { + public XSubCategoryEFRepository( + IXUnitOfWorks unitOfWorks, + XDataServiceConfiguration configuration, + IXSubCategoryKeyGenerator keyGenerator = null, + IXSubCategoryRepositoryEvents baseRepositoryEvents = null + ) : base( + unitOfWorks, + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XSubCategoryEntityHub.cs b/Providers/Entities/XSubCategoryEntityHub.cs new file mode 100644 index 0000000..7b0c790 --- /dev/null +++ b/Providers/Entities/XSubCategoryEntityHub.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.Logging; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xPushService.Base; + +namespace xCategoryService.Providers.Entities +{ + public class XSubCategoryEntityHub : XBaseEntityHub, IXSubCategoryEntityHub + { + public XSubCategoryEntityHub( + ILogger logger + ) : base(logger) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XSubCategoryInMemoryRepository.cs b/Providers/Entities/XSubCategoryInMemoryRepository.cs new file mode 100644 index 0000000..325ad58 --- /dev/null +++ b/Providers/Entities/XSubCategoryInMemoryRepository.cs @@ -0,0 +1,21 @@ +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Configuration; +using xDataService.Providers; + +namespace xCategoryService.Providers.Entities +{ + public class XSubCategoryInMemoryRepository : XBaseInMemoryRepository, IXSubCategoryRepository + { + public XSubCategoryInMemoryRepository( + XDataServiceConfiguration configuration, + IXSubCategoryKeyGenerator keyGenerator = null, + IXSubCategoryRepositoryEvents baseRepositoryEvents = null + ) : base( + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XSubCategoryKeyGenerator.cs b/Providers/Entities/XSubCategoryKeyGenerator.cs new file mode 100644 index 0000000..6767cd6 --- /dev/null +++ b/Providers/Entities/XSubCategoryKeyGenerator.cs @@ -0,0 +1,9 @@ +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Providers; + +namespace xCategoryService.Providers.Entities +{ + public class XSubCategoryKeyGenerator : XIntKeyGenerator, IXSubCategoryKeyGenerator + { } +} \ No newline at end of file diff --git a/Providers/Entities/XSubCategoryMongoRepository.cs b/Providers/Entities/XSubCategoryMongoRepository.cs new file mode 100644 index 0000000..120561e --- /dev/null +++ b/Providers/Entities/XSubCategoryMongoRepository.cs @@ -0,0 +1,25 @@ +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Configuration; +using xDataService.Providers; + +namespace xCategoryService.Providers.Entities +{ + public class XSubCategoryMongoRepository : XBaseMongoRepository, IXSubCategoryRepository + { + public XSubCategoryMongoRepository( + XDataBaseConfiguration dbConfiguration, + XDataServiceConfiguration configuration, + string collectionName = null, + IXSubCategoryKeyGenerator keyGenerator = null, + IXSubCategoryRepositoryEvents baseRepositoryEvents = null + ) : base( + dbConfiguration, + configuration, + collectionName, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XSubCategoryRepositoryEvents.cs b/Providers/Entities/XSubCategoryRepositoryEvents.cs new file mode 100644 index 0000000..67eeb5c --- /dev/null +++ b/Providers/Entities/XSubCategoryRepositoryEvents.cs @@ -0,0 +1,9 @@ +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Providers; + +namespace xCategoryService.Providers.Entities +{ + public class XSubCategoryRepositoryEvents : XBaseRepositoryEvents, IXSubCategoryRepositoryEvents + { } +} \ No newline at end of file diff --git a/Providers/Entities/XSubCategoryRepositoryProvider.cs b/Providers/Entities/XSubCategoryRepositoryProvider.cs new file mode 100644 index 0000000..109268b --- /dev/null +++ b/Providers/Entities/XSubCategoryRepositoryProvider.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.SignalR; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Configuration; +using xIdentityService.Interfaces; +using xPushService.Base; + +namespace xCategoryService.Providers.Entities +{ + public class XSubCategoryRepositoryProvider : XBaseEntityProvider, IXSubCategoryRepositoryProvider + { + public XSubCategoryRepositoryProvider( + IHubContext hub, + IXSubCategoryRepository repository, + XDataServiceConfiguration dataConfiguration, + IXIdentityProvider identityProvider = null + ) : base( + hub, + repository, + dataConfiguration, + identityProvider + ) + { } + } +} \ No newline at end of file diff --git a/Providers/GraphQL/XSubCategoryGraphQLTypeHelper.cs b/Providers/GraphQL/XSubCategoryGraphQLTypeHelper.cs new file mode 100644 index 0000000..cec88c3 --- /dev/null +++ b/Providers/GraphQL/XSubCategoryGraphQLTypeHelper.cs @@ -0,0 +1,25 @@ +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Configuration; +using xDataService.GraphQL; + +namespace xCategoryService.Providers.GraphQL +{ + public class XSubCategoryGraphQLTypeHelper : XBaseGraphQLTypeHelper, IXSubCategoryGraphQLTypeHelper + { + public XSubCategoryGraphQLTypeHelper( + XDataServiceConfiguration configuration + ) : base(configuration) + { } + + public override string GetInQueryCollectionName() + { + return "subCategories"; + } + + public override string GetInQuerySingleName() + { + return "subCategory"; + } + } +} \ No newline at end of file diff --git a/Providers/GraphQL/XSubCategoryGraphQuery.cs b/Providers/GraphQL/XSubCategoryGraphQuery.cs new file mode 100644 index 0000000..7ccc651 --- /dev/null +++ b/Providers/GraphQL/XSubCategoryGraphQuery.cs @@ -0,0 +1,22 @@ +using GraphQL.Types; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Configuration; +using xDataService.GraphQL; + +namespace xCategoryService.Providers.GraphQL +{ + public class XSubCategoryGraphQuery : XBaseGraphQLQuery + { + public XSubCategoryGraphQuery( + XDataServiceConfiguration configuration, + IXSubCategoryRepository repository, + IXSubCategoryGraphQLTypeHelper helper + ) : base( + configuration, + repository, + helper + ) + { } + } +} \ No newline at end of file diff --git a/Providers/GraphQL/XSubCategoryGraphSchema.cs b/Providers/GraphQL/XSubCategoryGraphSchema.cs new file mode 100644 index 0000000..12f1e33 --- /dev/null +++ b/Providers/GraphQL/XSubCategoryGraphSchema.cs @@ -0,0 +1,14 @@ +using System; +using GraphQL.Types; + +namespace xCategoryService.Providers.GraphQL +{ + public class XSubCategoryGraphSchema : Schema + { + public XSubCategoryGraphSchema(IServiceProvider services) : base(services) + { + Query = (XSubCategoryGraphQuery)services.GetService(typeof(XSubCategoryGraphQuery)); + } + + } +} \ No newline at end of file diff --git a/Providers/GraphQL/XSubCategoryGraphType.cs b/Providers/GraphQL/XSubCategoryGraphType.cs new file mode 100644 index 0000000..791095d --- /dev/null +++ b/Providers/GraphQL/XSubCategoryGraphType.cs @@ -0,0 +1,15 @@ +using xCategoryService.Models.Entities; +using xDataService.GraphQL; + +namespace xCategoryService.Providers.GraphQL +{ + public class XSubCategoryGraphType : XBaseGraphObjectType + { + public XSubCategoryGraphType() : base() + { + Field(x => x.Title); + Field(x => x.Description); + Field(x => x.References); + } + } +} \ No newline at end of file diff --git a/Providers/XSubCategoryDescriptionResourceProvider.cs b/Providers/XSubCategoryDescriptionResourceProvider.cs new file mode 100644 index 0000000..4fb6313 --- /dev/null +++ b/Providers/XSubCategoryDescriptionResourceProvider.cs @@ -0,0 +1,18 @@ +using xCategoryService.Interfaces; +using xStringService.Interfaces.Dtos; +using xStringService.Providers; + +namespace xCategoryService.Providers +{ + public class XSubCategoryDescriptionResourceProvider : XBaseItemResourceProvider, IXSubCategoryDescriptionResourceProvider + { + public XSubCategoryDescriptionResourceProvider( + string item, + IXStringServiceProvider stringProvider + ) : base( + item: "SubCatD", + stringProvider + ) + { } + } +} \ No newline at end of file diff --git a/Providers/XSubCategoryEntityRegisterar.cs b/Providers/XSubCategoryEntityRegisterar.cs new file mode 100644 index 0000000..0aa21e7 --- /dev/null +++ b/Providers/XSubCategoryEntityRegisterar.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using xCategoryService.Models.Entities; +using xDataService.Interfaces; +using xDataService.Providers; + +namespace xCategoryService.Providers +{ + public class XSubCategoryEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar + { + public XSubCategoryEntityRegisterar() + : base(nameof(XSubCategoryEntityRegisterar)) + { + // + // Add Entity ... + AddEntity(); + } + + /// + /// Configure Entities ... + /// + /// + public override void ConfigureEntities(ModelBuilder modelBuilder) + { + base.ConfigureEntities(modelBuilder); + } + } +} \ No newline at end of file diff --git a/Providers/XSubCategorySeederBase.cs b/Providers/XSubCategorySeederBase.cs new file mode 100644 index 0000000..426340b --- /dev/null +++ b/Providers/XSubCategorySeederBase.cs @@ -0,0 +1,24 @@ +using xCategoryService.Interfaces; +using xCategoryService.Interfaces.Entities; +using xCategoryService.Models.Entities; +using xDataService.Configuration; +using xDataService.Providers; + +namespace xCategoryService.Providers +{ + public abstract class XSubCategorySeederBase : XBaseDbSeeder, IXSubCategorySeeder + { + protected XSubCategorySeederBase( + string entity, + string database, + IXSubCategoryRepository repository, + XDataServiceConfiguration dataServiceConfiguration + ) : base( + entity, + database, + repository, + dataServiceConfiguration + ) + { } + } +} \ No newline at end of file