From 1e2eb030e87904276e6085a23314a7941cac50e5 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Wed, 11 Nov 2026 15:47:44 +0330 Subject: [PATCH] last works on Implementing XBotUser Entity and Repository Implementation based on xDataService ... --- .../Entities/XBotUserEntityConfiguration.cs | 2 +- DI/XDIHelperExtension.cs | 159 ++++++++++ Helper/XBotServiceHelper.cs | 278 ++++++++++++++++++ Interfaces/Dtos/IXBotUserDtoHub.cs | 9 + .../Dtos/IXBotUserRepositoryService.cs | 0 Interfaces/Dtos/IXBotUserServiceProvider.cs | 10 + Interfaces/Entities/IXBotUserEntityHub.cs | 8 + .../Entities/IXBotUserGraphQLTypeHelper.cs | 8 + .../Entities/IXBotUserRepositoryProvider.cs | 9 + Interfaces/Entities/IXBotUserSeeder.cs | 8 + Providers/Dtos/XBotUserDtoHub.cs | 16 + Providers/Dtos/XBotUserServiceProvider.cs | 27 ++ Providers/Entities/XBotUserEntityHub.cs | 15 + .../Entities/XBotUserInMemoryRepository.cs | 21 ++ Providers/Entities/XBotUserMongoRepository.cs | 25 ++ Providers/Entities/XBotUserSeederBase.cs | 23 ++ .../GraphQL/XBotUserGraphQLTypeHelper.cs | 28 ++ Providers/GraphQL/XBotUserGraphQuery.cs | 18 ++ Providers/GraphQL/XBotUserGraphSchema.cs | 13 + Providers/GraphQL/XBotUserGraphType.cs | 14 + Providers/XBotUserEntityRegisterar.cs | 34 +++ README.md | 2 +- xBotService.csproj | 1 + 23 files changed, 726 insertions(+), 2 deletions(-) create mode 100644 DI/XDIHelperExtension.cs create mode 100644 Helper/XBotServiceHelper.cs create mode 100644 Interfaces/Dtos/IXBotUserDtoHub.cs rename Interfaces/{Entities => }/Dtos/IXBotUserRepositoryService.cs (100%) create mode 100644 Interfaces/Dtos/IXBotUserServiceProvider.cs create mode 100644 Interfaces/Entities/IXBotUserEntityHub.cs create mode 100644 Interfaces/Entities/IXBotUserGraphQLTypeHelper.cs create mode 100644 Interfaces/Entities/IXBotUserRepositoryProvider.cs create mode 100644 Interfaces/Entities/IXBotUserSeeder.cs create mode 100644 Providers/Dtos/XBotUserDtoHub.cs create mode 100644 Providers/Dtos/XBotUserServiceProvider.cs create mode 100644 Providers/Entities/XBotUserEntityHub.cs create mode 100644 Providers/Entities/XBotUserInMemoryRepository.cs create mode 100644 Providers/Entities/XBotUserMongoRepository.cs create mode 100644 Providers/Entities/XBotUserSeederBase.cs create mode 100644 Providers/GraphQL/XBotUserGraphQLTypeHelper.cs create mode 100644 Providers/GraphQL/XBotUserGraphQuery.cs create mode 100644 Providers/GraphQL/XBotUserGraphSchema.cs create mode 100644 Providers/GraphQL/XBotUserGraphType.cs create mode 100644 Providers/XBotUserEntityRegisterar.cs diff --git a/Configuration/Entities/XBotUserEntityConfiguration.cs b/Configuration/Entities/XBotUserEntityConfiguration.cs index 4c4d52d..4180a80 100644 --- a/Configuration/Entities/XBotUserEntityConfiguration.cs +++ b/Configuration/Entities/XBotUserEntityConfiguration.cs @@ -10,7 +10,7 @@ namespace xBotService.Configuration.Entities { public override void Configure(EntityTypeBuilder builder) { - builder.ToTable(XBotServiceConstants.XBotUsersTable); + builder.ToTable(XBotServiceConstants.XBotUserTable); } } } \ No newline at end of file diff --git a/DI/XDIHelperExtension.cs b/DI/XDIHelperExtension.cs new file mode 100644 index 0000000..174acd5 --- /dev/null +++ b/DI/XDIHelperExtension.cs @@ -0,0 +1,159 @@ +using System; +using xDataService.Db; +using xDataService.DI; +using xCommons.Helpers; +using xCommons.Extensions; +using xDataService.Models; +using xExceptions.Constants; +using xBotService.Constants; +using xDataService.Constants; +using XBotUserService.Helpers; +using xHttpService.Interfaces; +using xBotService.Providers.Dtos; +using Microsoft.AspNetCore.Builder; +using xBotService.Interfaces.Entities.Dtos; +using Microsoft.Extensions.DependencyInjection; + +namespace xBotService.DI +{ + public static class XDIHelperExtension + { + /// + /// Register XBotService + /// + public static void AddXBotService( + this IServiceCollection services, + XRepositoryType repositoryType, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) + { + AddBotService( + contextType: null, + services: services, + lifeTime: lifeTime, + repositoryType: repositoryType + ); + } + + /// + /// Register XBotService with Context + /// + public static void AddXBotService( + this IServiceCollection services, + XRepositoryType repositoryType, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) where TContext : XDbContext + { + AddBotService( + services: services, + lifeTime: lifeTime, + contextType: typeof(TContext), + repositoryType: repositoryType + ); + } + + /// + /// Use XBotService Middleware + /// + public static void UseXBotService( + this IApplicationBuilder app, + bool isDevelopmentEnvironment = false + ) + { + // Using XBot Repository Descriptor + if (!descriptor.IsNull()) + { + app.UseXRepository( + descriptor: descriptor, + isDevelopmentEnvironment: isDevelopmentEnvironment + ); + } + } + + // + #region Private ... + private static XRepositoryDescriptor descriptor = null; + private static string XLogTag = XBotServiceConstants.XBotServiceDILogTag; + + private static void Log(string message) + { + Console.WriteLine($"{XLogTag} => {message}"); + } + + private static void AddBotService( + IServiceCollection services, + XRepositoryType repositoryType, + Type contextType = null, + ServiceLifetime lifeTime = ServiceLifetime.Scoped + ) + { + // + var exception = XException.InvalidArgs.ToException(); + + // + // Validate Services + if (services.IsNull()) + { + // + Log("Service Registration failed, services not provided ..."); + throw exception; + } + + // + // Check Requirements ... + var httpService = services.GetRegisteredService(); + if (httpService.IsNull()) + { + // + Log("Service Registration failed, HttpService 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; + } + + // + // Make Instance of Repository Descriptor + switch (repositoryType) + { + case XRepositoryType.EF: + descriptor = typeof(XBotServiceHelper) + .InvokeGenericMethod( + args: null, + runtimeType: contextType, + methodName: XBotServiceConstants.GetXBotUserEFRepositoryDescriptor + ); + break; + case XRepositoryType.Mongo: + // descriptor = XBotServiceHelper.GetXBotUserMongoRepositoryDescriptor(); + Log("MongoDB support not implemented yet for XBotService."); + break; + case XRepositoryType.InMemory: + // descriptor = XBotServiceHelper.GetXBotUserInMemoryRepositoryDescriptor(); + Log("InMemory support not implemented yet for XBotService."); + break; + } + + // + // Register XBotUser Repository Descriptor + if (!descriptor.IsNull()) + { + services.AddXRepository(lifeTime: lifeTime, descriptor: descriptor); + } + + // + // Register Dto Services + services.Add(new ServiceDescriptor(typeof(IXBotUserRepositoryService), typeof(XBotUserRepositoryService), lifeTime)); + Log("XBotService Registration Succeed ..."); + } + #endregion + } +} \ No newline at end of file diff --git a/Helper/XBotServiceHelper.cs b/Helper/XBotServiceHelper.cs new file mode 100644 index 0000000..3d84e4c --- /dev/null +++ b/Helper/XBotServiceHelper.cs @@ -0,0 +1,278 @@ +using GraphQL.Types; +using xDataService.Db; +using xDataService.Models; +using xDataService.Providers; +using xBotService.Models.Entities; +using xBotService.Providers.GraphQL; +using xBotService.Providers.Entities; +using xBotService.Interfaces.Entities; + +namespace XBotUserService.Helpers +{ + public static class XBotServiceHelper + { + // + #region EF Repository Descriptor Provider(s) ... + public static XEFRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserEFRepository, + TContext + > GetXBotUserEFRepositoryDescriptor() + where TContext : XDbContext + { + // + var result = new XEFRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserEFRepository, + TContext + >(); + + // + return result; + } + + public static XEFRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserEFRepository, + TContext, + IXBotUserSeeder, + TSeederImplementation + > GetXBotUserEFRepositoryDescriptor() + where TContext : XDbContext + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XEFRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserEFRepository, + TContext, + IXBotUserSeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + + // + #region Mongo Repository Descriptor Provider(s) ... + public static XMongoRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserMongoRepository + > GetXBotUserMongoRepositoryDescriptor() + { + // + var result = new XMongoRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserMongoRepository + >(); + + // + return result; + } + + public static XMongoRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserMongoRepository, + IXBotUserSeeder, + TSeederImplementation + > GetXBotUserMongoRepositoryDescriptor() + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XMongoRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserMongoRepository, + IXBotUserSeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + + // + #region InMemory Repository Descriptor Provider(s) ... + public static XInMemoryRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserInMemoryRepository + > GetXBotUserInMemoryRepositoryDescriptor() + { + // + var result = new XInMemoryRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserInMemoryRepository + >(); + + // + return result; + } + + public static XInMemoryRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserInMemoryRepository, + IXBotUserSeeder, + TSeederImplementation + > GetXBotUserInMemoryRepositoryDescriptor() + where TSeederImplementation : XBaseDbSeeder + { + // + var result = new XInMemoryRepositoryDescriptor< + XBotUser, + int, + IXBotUserKeyGenerator, + XBotUserKeyGenerator, + IXBotUserRepositoryEvents, + XBotUserRepositoryEvents, + XBotUserGraphType, + IntGraphType, + XBotUserGraphQuery, + IXBotUserGraphQLTypeHelper, + XBotUserGraphQLTypeHelper, + XBotUserGraphSchema, + IXBotUserRepository, + XBotUserInMemoryRepository, + IXBotUserSeeder, + TSeederImplementation + >(); + + // + return result; + } + #endregion + } +} \ No newline at end of file diff --git a/Interfaces/Dtos/IXBotUserDtoHub.cs b/Interfaces/Dtos/IXBotUserDtoHub.cs new file mode 100644 index 0000000..caa57bf --- /dev/null +++ b/Interfaces/Dtos/IXBotUserDtoHub.cs @@ -0,0 +1,9 @@ +using xBotService.Models.Dtos; +using xPushService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Dtos +{ + public interface IXBotUserDtoHub : IXBaseDtoHub + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/Dtos/IXBotUserRepositoryService.cs b/Interfaces/Dtos/IXBotUserRepositoryService.cs similarity index 100% rename from Interfaces/Entities/Dtos/IXBotUserRepositoryService.cs rename to Interfaces/Dtos/IXBotUserRepositoryService.cs diff --git a/Interfaces/Dtos/IXBotUserServiceProvider.cs b/Interfaces/Dtos/IXBotUserServiceProvider.cs new file mode 100644 index 0000000..888c557 --- /dev/null +++ b/Interfaces/Dtos/IXBotUserServiceProvider.cs @@ -0,0 +1,10 @@ +using xBotService.Models.Dtos; +using xPushService.Interfaces; +using xBotService.Models.Entities; +using xBotService.Providers.Dtos; + +namespace xBotService.Interfaces.Dtos +{ + public interface IXBotUserServiceProvider : IXBaseDtoProvider + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXBotUserEntityHub.cs b/Interfaces/Entities/IXBotUserEntityHub.cs new file mode 100644 index 0000000..a5df2fa --- /dev/null +++ b/Interfaces/Entities/IXBotUserEntityHub.cs @@ -0,0 +1,8 @@ +using xPushService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserEntityHub : IXBaseEntityHub + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXBotUserGraphQLTypeHelper.cs b/Interfaces/Entities/IXBotUserGraphQLTypeHelper.cs new file mode 100644 index 0000000..9efb865 --- /dev/null +++ b/Interfaces/Entities/IXBotUserGraphQLTypeHelper.cs @@ -0,0 +1,8 @@ +using xDataService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserGraphQLTypeHelper : IXBaseGraphQLTypeHelper + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXBotUserRepositoryProvider.cs b/Interfaces/Entities/IXBotUserRepositoryProvider.cs new file mode 100644 index 0000000..2960031 --- /dev/null +++ b/Interfaces/Entities/IXBotUserRepositoryProvider.cs @@ -0,0 +1,9 @@ +using xPushService.Interfaces; +using xBotService.Models.Entities; +using xBotService.Providers.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserRepositoryProvider : IXBaseEntityProvider + { } +} \ No newline at end of file diff --git a/Interfaces/Entities/IXBotUserSeeder.cs b/Interfaces/Entities/IXBotUserSeeder.cs new file mode 100644 index 0000000..f96e933 --- /dev/null +++ b/Interfaces/Entities/IXBotUserSeeder.cs @@ -0,0 +1,8 @@ +using xDataService.Interfaces; +using xBotService.Models.Entities; + +namespace xBotService.Interfaces.Entities +{ + public interface IXBotUserSeeder: IXBaseDbSeeder + { } +} \ No newline at end of file diff --git a/Providers/Dtos/XBotUserDtoHub.cs b/Providers/Dtos/XBotUserDtoHub.cs new file mode 100644 index 0000000..93a77b6 --- /dev/null +++ b/Providers/Dtos/XBotUserDtoHub.cs @@ -0,0 +1,16 @@ +using xPushService.Base; +using xBotService.Models.Dtos; +using xBotService.Interfaces.Dtos; +using xBotService.Models.Entities; +using Microsoft.Extensions.Logging; + +namespace xBotService.Providers.Dtos +{ + public class XBotUserDtoHub : XBaseDtoHub, IXBotUserDtoHub + { + public XBotUserDtoHub( + ILogger logger + ) : base(logger) + { } + } +} \ No newline at end of file diff --git a/Providers/Dtos/XBotUserServiceProvider.cs b/Providers/Dtos/XBotUserServiceProvider.cs new file mode 100644 index 0000000..e218fab --- /dev/null +++ b/Providers/Dtos/XBotUserServiceProvider.cs @@ -0,0 +1,27 @@ +using xPushService.Base; +using xBotService.Models.Dtos; +using xDataService.Configuration; +using xBotService.Interfaces.Dtos; +using xBotService.Models.Entities; +using xIdentityService.Interfaces; +using Microsoft.AspNetCore.SignalR; +using xBotService.Interfaces.Entities.Dtos; + +namespace xBotService.Providers.Dtos +{ + public class XBotUserServiceProvider : XBaseDtoProvider, IXBotUserServiceProvider + { + public XBotUserServiceProvider( + IHubContext hub, + XDataServiceConfiguration dataConfiguration, + IXBotUserRepositoryService service, + IXIdentityProvider identityProvider = null + ) : base( + hub, + dataConfiguration, + service, + identityProvider + ) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XBotUserEntityHub.cs b/Providers/Entities/XBotUserEntityHub.cs new file mode 100644 index 0000000..3801136 --- /dev/null +++ b/Providers/Entities/XBotUserEntityHub.cs @@ -0,0 +1,15 @@ +using xPushService.Base; +using xBotService.Models.Entities; +using Microsoft.Extensions.Logging; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserEntityHub : XBaseEntityHub, IXBotUserEntityHub + { + public XBotUserEntityHub( + ILogger logger + ) : base(logger) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XBotUserInMemoryRepository.cs b/Providers/Entities/XBotUserInMemoryRepository.cs new file mode 100644 index 0000000..77b247b --- /dev/null +++ b/Providers/Entities/XBotUserInMemoryRepository.cs @@ -0,0 +1,21 @@ +using xDataService.Providers; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserInMemoryRepository : XBaseInMemoryRepository, IXBotUserRepository + { + public XBotUserInMemoryRepository( + XDataServiceConfiguration configuration, + IXBotUserKeyGenerator keyGenerator = null, + IXBotUserRepositoryEvents baseRepositoryEvents = null + ) : base( + configuration, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XBotUserMongoRepository.cs b/Providers/Entities/XBotUserMongoRepository.cs new file mode 100644 index 0000000..16cf049 --- /dev/null +++ b/Providers/Entities/XBotUserMongoRepository.cs @@ -0,0 +1,25 @@ +using xDataService.Providers; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public class XBotUserMongoRepository : XBaseMongoRepository, IXBotUserRepository + { + public XBotUserMongoRepository( + XDataBaseConfiguration dbConfiguration, + XDataServiceConfiguration configuration, + string collectionName = null, + IXBotUserKeyGenerator keyGenerator = null, + IXBotUserRepositoryEvents baseRepositoryEvents = null + ) : base( + dbConfiguration, + configuration, + collectionName, + keyGenerator, + baseRepositoryEvents + ) + { } + } +} \ No newline at end of file diff --git a/Providers/Entities/XBotUserSeederBase.cs b/Providers/Entities/XBotUserSeederBase.cs new file mode 100644 index 0000000..66b908f --- /dev/null +++ b/Providers/Entities/XBotUserSeederBase.cs @@ -0,0 +1,23 @@ +using xDataService.Providers; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.Entities +{ + public abstract class XBotUserSeederBase : XBaseDbSeeder, IXBotUserSeeder + { + protected XBotUserSeederBase( + string entity, + string database, + IXBotUserRepository repository, + XDataServiceConfiguration dataServiceConfiguration + ) : base( + entity, + database, + repository, + dataServiceConfiguration + ) + { } + } +} \ No newline at end of file diff --git a/Providers/GraphQL/XBotUserGraphQLTypeHelper.cs b/Providers/GraphQL/XBotUserGraphQLTypeHelper.cs new file mode 100644 index 0000000..410adcb --- /dev/null +++ b/Providers/GraphQL/XBotUserGraphQLTypeHelper.cs @@ -0,0 +1,28 @@ +using xDataService.GraphQL; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; +using xBotService.Constants; + +namespace xBotService.Providers.GraphQL +{ + public class XBotUserGraphQLTypeHelper : XBaseGraphQLTypeHelper, IXBotUserGraphQLTypeHelper + { + public XBotUserGraphQLTypeHelper( + XDataServiceConfiguration configuration + ) + : base(configuration) + { + } + + public override string GetInQueryCollectionName() + { + return XBotServiceConstants.XBotUserCollectionName; + } + + public override string GetInQuerySingleName() + { + return XBotServiceConstants.XBotUserSingleName; + } + } +} \ No newline at end of file diff --git a/Providers/GraphQL/XBotUserGraphQuery.cs b/Providers/GraphQL/XBotUserGraphQuery.cs new file mode 100644 index 0000000..130753a --- /dev/null +++ b/Providers/GraphQL/XBotUserGraphQuery.cs @@ -0,0 +1,18 @@ +using GraphQL.Types; +using xDataService.GraphQL; +using xDataService.Configuration; +using xBotService.Models.Entities; +using xBotService.Interfaces.Entities; + +namespace xBotService.Providers.GraphQL +{ + public class XBotUserGraphQuery : XBaseGraphQLQuery + { + public XBotUserGraphQuery( + XDataServiceConfiguration configuration, + IXBotUserRepository repository, + IXBotUserGraphQLTypeHelper helper + ) : base(configuration, repository, helper) + { } + } +} \ No newline at end of file diff --git a/Providers/GraphQL/XBotUserGraphSchema.cs b/Providers/GraphQL/XBotUserGraphSchema.cs new file mode 100644 index 0000000..daac8e8 --- /dev/null +++ b/Providers/GraphQL/XBotUserGraphSchema.cs @@ -0,0 +1,13 @@ +using System; +using GraphQL.Types; + +namespace xBotService.Providers.GraphQL +{ + public class XBotUserGraphSchema : Schema + { + public XBotUserGraphSchema(IServiceProvider services) : base(services) + { + Query = (XBotUserGraphQuery)services.GetService(typeof(XBotUserGraphQuery)); + } + } +} \ No newline at end of file diff --git a/Providers/GraphQL/XBotUserGraphType.cs b/Providers/GraphQL/XBotUserGraphType.cs new file mode 100644 index 0000000..b570a74 --- /dev/null +++ b/Providers/GraphQL/XBotUserGraphType.cs @@ -0,0 +1,14 @@ +using xDataService.GraphQL; +using xBotService.Models.Entities; + +namespace xBotService.Providers.GraphQL +{ + public class XBotUserGraphType : XBaseGraphObjectType + { + public XBotUserGraphType() : base() + { + Field(x => x.UserId); + Field(x => x.BotUserName); + } + } +} \ No newline at end of file diff --git a/Providers/XBotUserEntityRegisterar.cs b/Providers/XBotUserEntityRegisterar.cs new file mode 100644 index 0000000..41c3ebb --- /dev/null +++ b/Providers/XBotUserEntityRegisterar.cs @@ -0,0 +1,34 @@ +using xDataService.Providers; +using xDataService.Interfaces; +using xBotService.Models.Entities; +using Microsoft.EntityFrameworkCore; +using xBotService.Configuration.Entities; + +namespace xBotService.Providers +{ + public class XBotUserEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar + { + public XBotUserEntityRegisterar() + : base(nameof(XBotUserEntityRegisterar)) + { + // + // Add XBotUser Entity ... + AddEntity(); + } + + /// + /// Configure Entities ... + /// + /// + public override void ConfigureEntities(ModelBuilder modelBuilder) + { + // + // Configure Entity Using Provided ... + modelBuilder + .ApplyConfigurationsFromAssembly(typeof(XBotUserEntityConfiguration).Assembly); + + // + base.ConfigureEntities(modelBuilder); + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index 25c0e00..6f0808f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# xLoggingService +# xBotService provide all commonly used actions/extensions and classes which required to Bot Management Feature in xDashboard project. diff --git a/xBotService.csproj b/xBotService.csproj index a475e40..1961264 100644 --- a/xBotService.csproj +++ b/xBotService.csproj @@ -30,6 +30,7 @@ +