1012 lines
31 KiB
Plaintext
1012 lines
31 KiB
Plaintext
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Configuration\Entities\XBotUserEntityConfiguration.cs
|
|
|
|
using xBotService.Constants;
|
|
using xDataService.Providers;
|
|
using xBotService.Models.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace xBotService.Configuration.Entities
|
|
{
|
|
public class XBotUserEntityConfiguration: XBaseEntityTypeConfiguration<XBotUser, int>
|
|
{
|
|
public override void Configure(EntityTypeBuilder<XBotUser> builder)
|
|
{
|
|
builder.ToTable(XBotServiceConstants.XBotUserTable);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\ConfigurationNodeNames.cs
|
|
|
|
namespace xBotService.Constants
|
|
{
|
|
public partial struct ConfigurationNodeNames
|
|
{
|
|
public const string BOT_SERVICE_NODE = "BotServiceConfiguration";
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Constants\XBotServiceConstants.cs
|
|
|
|
namespace xBotService.Constants
|
|
{
|
|
public struct XBotServiceConstants
|
|
{
|
|
//
|
|
// Bot Service Log Tag ...
|
|
public const string XBotServiceDILogTag = "XBotService";
|
|
|
|
//
|
|
// Table Mapping ...
|
|
public const string XBotUserTable = "BotUsers";
|
|
|
|
//
|
|
// GraphQL Mappings ...
|
|
public const string XBotUserSingleName = "botUser";
|
|
public const string XBotUserCollectionName = "botUsers";
|
|
|
|
//
|
|
// Hubs ...
|
|
public const string XBotUserDtoHub = "botUserDto";
|
|
public const string XBotUserEntityHub = "botUserEntity";
|
|
|
|
//
|
|
// Helper Method Names ...
|
|
public const string GetXBotUserEFRepositoryDescriptor = "GetXBotUserEFRepositoryDescriptor";
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\DI\XDIHelperExtension.cs
|
|
|
|
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
|
|
{
|
|
/// <summary>
|
|
/// Register XBotService
|
|
/// </summary>
|
|
public static void AddXBotService(
|
|
this IServiceCollection services,
|
|
XRepositoryType repositoryType,
|
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
|
)
|
|
{
|
|
AddBotService(
|
|
contextType: null,
|
|
services: services,
|
|
lifeTime: lifeTime,
|
|
repositoryType: repositoryType
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Register XBotService with Context
|
|
/// </summary>
|
|
public static void AddXBotService<TContext>(
|
|
this IServiceCollection services,
|
|
XRepositoryType repositoryType,
|
|
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
|
) where TContext : XDbContext
|
|
{
|
|
AddBotService(
|
|
services: services,
|
|
lifeTime: lifeTime,
|
|
contextType: typeof(TContext),
|
|
repositoryType: repositoryType
|
|
);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Use XBotService Middleware
|
|
/// </summary>
|
|
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<IXHttpProvider>();
|
|
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<XRepositoryDescriptor>(
|
|
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
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Helper\XBotServiceHelper.cs
|
|
|
|
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>,
|
|
TContext
|
|
> GetXBotUserEFRepositoryDescriptor<TContext>()
|
|
where TContext : XDbContext
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XBotUser,
|
|
int,
|
|
IXBotUserKeyGenerator,
|
|
XBotUserKeyGenerator,
|
|
IXBotUserRepositoryEvents,
|
|
XBotUserRepositoryEvents,
|
|
XBotUserGraphType,
|
|
IntGraphType,
|
|
XBotUserGraphQuery,
|
|
IXBotUserGraphQLTypeHelper,
|
|
XBotUserGraphQLTypeHelper,
|
|
XBotUserGraphSchema,
|
|
IXBotUserRepository,
|
|
XBotUserEFRepository<TContext>,
|
|
TContext
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
public static XEFRepositoryDescriptor<
|
|
XBotUser,
|
|
int,
|
|
IXBotUserKeyGenerator,
|
|
XBotUserKeyGenerator,
|
|
IXBotUserRepositoryEvents,
|
|
XBotUserRepositoryEvents,
|
|
XBotUserGraphType,
|
|
IntGraphType,
|
|
XBotUserGraphQuery,
|
|
IXBotUserGraphQLTypeHelper,
|
|
XBotUserGraphQLTypeHelper,
|
|
XBotUserGraphSchema,
|
|
IXBotUserRepository,
|
|
XBotUserEFRepository<TContext>,
|
|
TContext,
|
|
IXBotUserSeeder,
|
|
TSeederImplementation
|
|
> GetXBotUserEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
|
where TContext : XDbContext
|
|
where TSeederImplementation : XBaseDbSeeder<XBotUser, int>
|
|
{
|
|
//
|
|
var result = new XEFRepositoryDescriptor<
|
|
XBotUser,
|
|
int,
|
|
IXBotUserKeyGenerator,
|
|
XBotUserKeyGenerator,
|
|
IXBotUserRepositoryEvents,
|
|
XBotUserRepositoryEvents,
|
|
XBotUserGraphType,
|
|
IntGraphType,
|
|
XBotUserGraphQuery,
|
|
IXBotUserGraphQLTypeHelper,
|
|
XBotUserGraphQLTypeHelper,
|
|
XBotUserGraphSchema,
|
|
IXBotUserRepository,
|
|
XBotUserEFRepository<TContext>,
|
|
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<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XBotUser, int>
|
|
{
|
|
//
|
|
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<TSeederImplementation>()
|
|
where TSeederImplementation : XBaseDbSeeder<XBotUser, int>
|
|
{
|
|
//
|
|
var result = new XInMemoryRepositoryDescriptor<
|
|
XBotUser,
|
|
int,
|
|
IXBotUserKeyGenerator,
|
|
XBotUserKeyGenerator,
|
|
IXBotUserRepositoryEvents,
|
|
XBotUserRepositoryEvents,
|
|
XBotUserGraphType,
|
|
IntGraphType,
|
|
XBotUserGraphQuery,
|
|
IXBotUserGraphQLTypeHelper,
|
|
XBotUserGraphQLTypeHelper,
|
|
XBotUserGraphSchema,
|
|
IXBotUserRepository,
|
|
XBotUserInMemoryRepository,
|
|
IXBotUserSeeder,
|
|
TSeederImplementation
|
|
>();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Dtos\IXBotUserDtoHub.cs
|
|
|
|
using xBotService.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Interfaces.Dtos
|
|
{
|
|
public interface IXBotUserDtoHub : IXBaseDtoHub<XBotUser, XBotUserDto, int>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Dtos\IXBotUserRepositoryService.cs
|
|
|
|
using xBotService.Models.Dtos;
|
|
using xDataService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Interfaces.Entities.Dtos
|
|
{
|
|
public interface IXBotUserRepositoryService : IXBaseRepositoryService<XBotUser, XBotUserDto, int>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Dtos\IXBotUserServiceProvider.cs
|
|
|
|
using xBotService.Models.Dtos;
|
|
using xPushService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
using xBotService.Providers.Dtos;
|
|
|
|
namespace xBotService.Interfaces.Dtos
|
|
{
|
|
public interface IXBotUserServiceProvider : IXBaseDtoProvider<XBotUser, XBotUserDto, int, XBotUserDtoHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserEntityHub.cs
|
|
|
|
using xPushService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Interfaces.Entities
|
|
{
|
|
public interface IXBotUserEntityHub : IXBaseEntityHub<XBotUser, int>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserGraphQLTypeHelper.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Interfaces.Entities
|
|
{
|
|
public interface IXBotUserGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XBotUser, int>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserKeyGenerator.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Interfaces.Entities
|
|
{
|
|
public interface IXBotUserKeyGenerator : IXKeyGenerator<XBotUser, int>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserRepository.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Interfaces.Entities
|
|
{
|
|
public interface IXBotUserRepository : IXBaseRepository<XBotUser, int>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserRepositoryEvents.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Interfaces.Entities
|
|
{
|
|
public interface IXBotUserRepositoryEvents : IXBaseRepositoryEvents<XBotUser>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserRepositoryProvider.cs
|
|
|
|
using xPushService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
using xBotService.Providers.Entities;
|
|
|
|
namespace xBotService.Interfaces.Entities
|
|
{
|
|
public interface IXBotUserRepositoryProvider : IXBaseEntityProvider<XBotUser, int, XBotUserEntityHub>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Interfaces\Entities\IXBotUserSeeder.cs
|
|
|
|
using xDataService.Interfaces;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Interfaces.Entities
|
|
{
|
|
public interface IXBotUserSeeder: IXBaseDbSeeder<XBotUser, int>
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Models\Dtos\XBotUserDto.cs
|
|
|
|
using xModels.Base;
|
|
using xModels.Dtos;
|
|
|
|
namespace xBotService.Models.Dtos
|
|
{
|
|
/// <summary>
|
|
/// Bot User / System User Relation ...
|
|
/// </summary>
|
|
public class XBotUserDto : XBaseIntIDEntityDto
|
|
{
|
|
/// <summary>
|
|
/// User Id ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string UserId { get; set; }
|
|
|
|
/// <summary>
|
|
/// System Person Information ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public virtual XPersonDto User { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Chat Bot User Name ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string BotUserName { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Models\Entities\XBotUser.cs
|
|
|
|
using xModels.Base;
|
|
|
|
namespace xBotService.Models.Entities
|
|
{
|
|
/// <summary>
|
|
/// Bot User / System User Relation ...
|
|
/// </summary>
|
|
public class XBotUser : XBaseIntIDEntity
|
|
{
|
|
/// <summary>
|
|
/// User Id ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string UserId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Chat Bot User Name ...
|
|
/// </summary>
|
|
/// <value></value>
|
|
public string BotUserName { get; set; }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\XBotUserEntityRegisterar.cs
|
|
|
|
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<XBotUser, int>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure Entities ...
|
|
/// </summary>
|
|
/// <param name="modelBuilder"></param>
|
|
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
|
{
|
|
//
|
|
// Configure Entity Using Provided ...
|
|
modelBuilder
|
|
.ApplyConfigurationsFromAssembly(typeof(XBotUserEntityConfiguration).Assembly);
|
|
|
|
//
|
|
base.ConfigureEntities(modelBuilder);
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Dtos\XBotUserDtoHub.cs
|
|
|
|
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<XBotUser, XBotUserDto, int>, IXBotUserDtoHub
|
|
{
|
|
public XBotUserDtoHub(
|
|
ILogger<XBotUserDtoHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Dtos\XBotUserRepositoryService.cs
|
|
|
|
using AutoMapper;
|
|
using xDataService.Providers;
|
|
using xBotService.Models.Dtos;
|
|
using xBotService.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using xBotService.Interfaces.Entities;
|
|
using xBotService.Interfaces.Entities.Dtos;
|
|
|
|
namespace xBotService.Providers.Dtos
|
|
{
|
|
public class XBotUserRepositoryService : XBaseRepositoryService<XBotUser, XBotUserDto, int>, IXBotUserRepositoryService
|
|
{
|
|
public XBotUserRepositoryService(
|
|
IXBotUserRepository repository,
|
|
IEnumerable<Profile> mapperProfiles = null
|
|
) : base(repository, mapperProfiles)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Dtos\XBotUserServiceProvider.cs
|
|
|
|
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<XBotUser, XBotUserDto, int, XBotUserDtoHub>, IXBotUserServiceProvider
|
|
{
|
|
public XBotUserServiceProvider(
|
|
IHubContext<XBotUserDtoHub> hub,
|
|
XDataServiceConfiguration dataConfiguration,
|
|
IXBotUserRepositoryService service,
|
|
IXIdentityProvider identityProvider = null
|
|
) : base(
|
|
hub,
|
|
dataConfiguration,
|
|
service,
|
|
identityProvider
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserEFRepository.cs
|
|
|
|
using xDataService.Db;
|
|
using xDataService.Providers;
|
|
using xDataService.Interfaces;
|
|
using xDataService.Configuration;
|
|
using xBotService.Models.Entities;
|
|
using xBotService.Interfaces.Entities;
|
|
|
|
namespace xBotService.Providers.Entities
|
|
{
|
|
public class XBotUserEFRepository<TContext> : XBaseEFRepository<XBotUser, int, TContext>, IXBotUserRepository
|
|
where TContext : XDbContext
|
|
{
|
|
public XBotUserEFRepository(
|
|
IXUnitOfWorks<TContext> unitOfWorks,
|
|
XDataServiceConfiguration configuration,
|
|
IXBotUserKeyGenerator keyGenerator = null,
|
|
IXBotUserRepositoryEvents baseRepositoryEvents = null
|
|
) : base(unitOfWorks, configuration, keyGenerator, baseRepositoryEvents)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserEntityHub.cs
|
|
|
|
using xPushService.Base;
|
|
using xBotService.Models.Entities;
|
|
using Microsoft.Extensions.Logging;
|
|
using xBotService.Interfaces.Entities;
|
|
|
|
namespace xBotService.Providers.Entities
|
|
{
|
|
public class XBotUserEntityHub : XBaseEntityHub<XBotUser, int>, IXBotUserEntityHub
|
|
{
|
|
public XBotUserEntityHub(
|
|
ILogger<XBotUserEntityHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserInMemoryRepository.cs
|
|
|
|
using xDataService.Providers;
|
|
using xDataService.Configuration;
|
|
using xBotService.Models.Entities;
|
|
using xBotService.Interfaces.Entities;
|
|
|
|
namespace xBotService.Providers.Entities
|
|
{
|
|
public class XBotUserInMemoryRepository : XBaseInMemoryRepository<XBotUser, int>, IXBotUserRepository
|
|
{
|
|
public XBotUserInMemoryRepository(
|
|
XDataServiceConfiguration configuration,
|
|
IXBotUserKeyGenerator keyGenerator = null,
|
|
IXBotUserRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
configuration,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserKeyGenerator.cs
|
|
|
|
using xDataService.Providers;
|
|
using xBotService.Models.Entities;
|
|
using xBotService.Interfaces.Entities;
|
|
|
|
namespace xBotService.Providers.Entities
|
|
{
|
|
public class XBotUserKeyGenerator : XIntKeyGenerator<XBotUser>, IXBotUserKeyGenerator
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserMongoRepository.cs
|
|
|
|
using xDataService.Providers;
|
|
using xDataService.Configuration;
|
|
using xBotService.Models.Entities;
|
|
using xBotService.Interfaces.Entities;
|
|
|
|
namespace xBotService.Providers.Entities
|
|
{
|
|
public class XBotUserMongoRepository : XBaseMongoRepository<XBotUser, int>, IXBotUserRepository
|
|
{
|
|
public XBotUserMongoRepository(
|
|
XDataBaseConfiguration dbConfiguration,
|
|
XDataServiceConfiguration configuration,
|
|
string collectionName = null,
|
|
IXBotUserKeyGenerator keyGenerator = null,
|
|
IXBotUserRepositoryEvents baseRepositoryEvents = null
|
|
) : base(
|
|
dbConfiguration,
|
|
configuration,
|
|
collectionName,
|
|
keyGenerator,
|
|
baseRepositoryEvents
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserRepositoryEvents.cs
|
|
|
|
using xDataService.Providers;
|
|
using xBotService.Models.Entities;
|
|
using xBotService.Interfaces.Entities;
|
|
|
|
namespace xBotService.Providers.Entities
|
|
{
|
|
public class XBotUserRepositoryEvents : XBaseRepositoryEvents<XBotUser>, IXBotUserRepositoryEvents
|
|
{ }
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\Entities\XBotUserSeederBase.cs
|
|
|
|
using xDataService.Providers;
|
|
using xDataService.Configuration;
|
|
using xBotService.Models.Entities;
|
|
using xBotService.Interfaces.Entities;
|
|
|
|
namespace xBotService.Providers.Entities
|
|
{
|
|
public abstract class XBotUserSeederBase : XBaseDbSeeder<XBotUser, int>, IXBotUserSeeder
|
|
{
|
|
protected XBotUserSeederBase(
|
|
string entity,
|
|
string database,
|
|
IXBotUserRepository repository,
|
|
XDataServiceConfiguration dataServiceConfiguration
|
|
) : base(
|
|
entity,
|
|
database,
|
|
repository,
|
|
dataServiceConfiguration
|
|
)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\GraphQL\XBotUserGraphQLTypeHelper.cs
|
|
|
|
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<XBotUser, int>, IXBotUserGraphQLTypeHelper
|
|
{
|
|
public XBotUserGraphQLTypeHelper(
|
|
XDataServiceConfiguration configuration
|
|
)
|
|
: base(configuration)
|
|
{
|
|
}
|
|
|
|
public override string GetInQueryCollectionName()
|
|
{
|
|
return XBotServiceConstants.XBotUserCollectionName;
|
|
}
|
|
|
|
public override string GetInQuerySingleName()
|
|
{
|
|
return XBotServiceConstants.XBotUserSingleName;
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\GraphQL\XBotUserGraphQuery.cs
|
|
|
|
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<XBotUser, int, XBotUserGraphType, IntGraphType>
|
|
{
|
|
public XBotUserGraphQuery(
|
|
XDataServiceConfiguration configuration,
|
|
IXBotUserRepository repository,
|
|
IXBotUserGraphQLTypeHelper helper
|
|
) : base(configuration, repository, helper)
|
|
{ }
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\GraphQL\XBotUserGraphSchema.cs
|
|
|
|
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));
|
|
}
|
|
}
|
|
}
|
|
|
|
### FILE: C:\Users\saherelm\Documents\Projects\xSaherelmWorkspace\Modules\xBotService\Providers\GraphQL\XBotUserGraphType.cs
|
|
|
|
using xDataService.GraphQL;
|
|
using xBotService.Models.Entities;
|
|
|
|
namespace xBotService.Providers.GraphQL
|
|
{
|
|
public class XBotUserGraphType : XBaseGraphObjectType<XBotUser, int>
|
|
{
|
|
public XBotUserGraphType() : base()
|
|
{
|
|
Field(x => x.UserId);
|
|
Field(x => x.BotUserName);
|
|
}
|
|
}
|
|
}
|