Complete SubCategory Data Models and Implementations ...
This commit is contained in:
@@ -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<XSubCategory, int>
|
||||
{
|
||||
public override void Configure(EntityTypeBuilder<XSubCategory> builder)
|
||||
{
|
||||
builder.ToTable("SubCategories");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, int>, IXBaseRepositoryController<XSubCategory, int>
|
||||
{
|
||||
protected XSubCategoryRepositoryControllerBase(
|
||||
ILogger<XSubCategoryRepositoryControllerBase> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
XValidationProvider validationProvider,
|
||||
IXSubCategoryRepository repository,
|
||||
Func<IQueryable<XSubCategory>, IOrderedQueryable<XSubCategory>> defaultOrderBuilder = null,
|
||||
Func<IQueryable<XSubCategory>, IIncludableQueryable<XSubCategory, object>> defaultIncludeBuilder = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
validationProvider,
|
||||
repository,
|
||||
defaultOrderBuilder,
|
||||
defaultIncludeBuilder
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, int, XSubCategoryEntityHub>, IXBaseRepositoryProviderController<XSubCategory, int, XSubCategoryEntityHub>
|
||||
{
|
||||
protected XSubCategoryRepositoryProviderControllerBase(
|
||||
ILogger<XSubCategoryRepositoryProviderControllerBase> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXSubCategoryRepositoryProvider provider,
|
||||
Func<IQueryable<XSubCategory>, IOrderedQueryable<XSubCategory>> defaultOrderBuilder = null,
|
||||
Func<IQueryable<XSubCategory>, IIncludableQueryable<XSubCategory, object>> defaultIncludeBuilder = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
provider,
|
||||
defaultOrderBuilder,
|
||||
defaultIncludeBuilder
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, XSubCategoryDto, int>, IXBaseServiceController<XSubCategory, XSubCategoryDto, int>
|
||||
{
|
||||
protected XSubCategoryServiceControllerBase(
|
||||
ILogger<XSubCategoryServiceControllerBase> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
XValidationProvider validationProvider,
|
||||
IXSubCategoryRepositoryService repositoryService,
|
||||
Func<IQueryable<XSubCategory>, IOrderedQueryable<XSubCategory>> defaultOrderBuilder = null,
|
||||
Func<IQueryable<XSubCategory>, IIncludableQueryable<XSubCategory, object>> defaultIncludeBuilder = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
validationProvider,
|
||||
repositoryService,
|
||||
defaultOrderBuilder,
|
||||
defaultIncludeBuilder
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, XSubCategoryDto, int, XSubCategoryDtoHub>, IXBaseServiceProviderController<XSubCategory, XSubCategoryDto, int, XSubCategoryDtoHub>
|
||||
{
|
||||
protected XSubCategoryServiceProviderControllerBase(
|
||||
ILogger<XSubCategoryServiceProviderControllerBase> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider,
|
||||
IXSubCategoryServiceProvider provider,
|
||||
Func<IQueryable<XSubCategory>, IOrderedQueryable<XSubCategory>> defaultOrderBuilder = null,
|
||||
Func<IQueryable<XSubCategory>, IIncludableQueryable<XSubCategory, object>> defaultIncludeBuilder = null
|
||||
) : base(
|
||||
logger,
|
||||
appConfiguration,
|
||||
identityProvider,
|
||||
validationProvider,
|
||||
provider,
|
||||
defaultOrderBuilder,
|
||||
defaultIncludeBuilder
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Register Service ...
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="repositoryType"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
public static void AddXCategoryService(
|
||||
this IServiceCollection services,
|
||||
XRepositoryType repositoryType,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||
)
|
||||
{
|
||||
AddCategoryService(
|
||||
contextType: null,
|
||||
services: services,
|
||||
lifeTime: lifeTime,
|
||||
repositoryType: repositoryType
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Service ...
|
||||
/// </summary>
|
||||
/// <typeparam name="TContext"></typeparam>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="repositoryType"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
public static void AddXCategoryService<TContext>(
|
||||
this IServiceCollection services,
|
||||
XRepositoryType repositoryType,
|
||||
ServiceLifetime lifeTime = ServiceLifetime.Scoped
|
||||
)
|
||||
where TContext : XDbContext
|
||||
{
|
||||
AddCategoryService(
|
||||
services: services,
|
||||
lifeTime: lifeTime,
|
||||
contextType: typeof(TContext),
|
||||
repositoryType: repositoryType
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use XSubCategoryService Middleware ...
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="isDevelopmentEnvironment"></param>
|
||||
public static void UseXCategoryService(
|
||||
this IApplicationBuilder app,
|
||||
bool isDevelopmentEnvironment = false
|
||||
)
|
||||
{
|
||||
//
|
||||
#region Using XSubCategory Hubs ...
|
||||
//
|
||||
var pushHelper = new XPushServiceHelper();
|
||||
|
||||
//
|
||||
pushHelper.AddHub<XSubCategoryDtoHub>("tagDto");
|
||||
pushHelper.AddHub<XSubCategoryEntityHub>("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;
|
||||
|
||||
/// <summary>
|
||||
/// a LogTag for Service ...
|
||||
/// </summary>
|
||||
private static string XLogTag = "XCategoryService";
|
||||
|
||||
/// <summary>
|
||||
/// print a log in Console ...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
private static void Log(string message)
|
||||
{
|
||||
Console.WriteLine($"{XLogTag} => {message}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Service ...
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
/// <param name="repositoryType"></param>
|
||||
/// <param name="contextType"></param>
|
||||
/// <param name="lifeTime"></param>
|
||||
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<XRepositoryDescriptor>(
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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>,
|
||||
TContext
|
||||
> GetXSubCategoryEFRepositoryDescriptor<TContext>()
|
||||
where TContext : XDbContext
|
||||
{
|
||||
//
|
||||
var result = new XEFRepositoryDescriptor<
|
||||
XSubCategory,
|
||||
int,
|
||||
IXSubCategoryKeyGenerator,
|
||||
XSubCategoryKeyGenerator,
|
||||
IXSubCategoryRepositoryEvents,
|
||||
XSubCategoryRepositoryEvents,
|
||||
XSubCategoryGraphType,
|
||||
IntGraphType,
|
||||
XSubCategoryGraphQuery,
|
||||
IXSubCategoryGraphQLTypeHelper,
|
||||
XSubCategoryGraphQLTypeHelper,
|
||||
XSubCategoryGraphSchema,
|
||||
IXSubCategoryRepository,
|
||||
XSubCategoryEFRepository<TContext>,
|
||||
TContext
|
||||
>();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
public static XEFRepositoryDescriptor<
|
||||
XSubCategory,
|
||||
int,
|
||||
IXSubCategoryKeyGenerator,
|
||||
XSubCategoryKeyGenerator,
|
||||
IXSubCategoryRepositoryEvents,
|
||||
XSubCategoryRepositoryEvents,
|
||||
XSubCategoryGraphType,
|
||||
IntGraphType,
|
||||
XSubCategoryGraphQuery,
|
||||
IXSubCategoryGraphQLTypeHelper,
|
||||
XSubCategoryGraphQLTypeHelper,
|
||||
XSubCategoryGraphSchema,
|
||||
IXSubCategoryRepository,
|
||||
XSubCategoryEFRepository<TContext>,
|
||||
TContext,
|
||||
IXSubCategorySeeder,
|
||||
TSeederImplementation
|
||||
> GetXSubCategoryEFRepositoryDescriptor<TContext, TSeederImplementation>()
|
||||
where TContext : XDbContext
|
||||
where TSeederImplementation : XBaseDbSeeder<XSubCategory, int>
|
||||
{
|
||||
//
|
||||
var result = new XEFRepositoryDescriptor<
|
||||
XSubCategory,
|
||||
int,
|
||||
IXSubCategoryKeyGenerator,
|
||||
XSubCategoryKeyGenerator,
|
||||
IXSubCategoryRepositoryEvents,
|
||||
XSubCategoryRepositoryEvents,
|
||||
XSubCategoryGraphType,
|
||||
IntGraphType,
|
||||
XSubCategoryGraphQuery,
|
||||
IXSubCategoryGraphQLTypeHelper,
|
||||
XSubCategoryGraphQLTypeHelper,
|
||||
XSubCategoryGraphSchema,
|
||||
IXSubCategoryRepository,
|
||||
XSubCategoryEFRepository<TContext>,
|
||||
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<TSeederImplementation>()
|
||||
where TSeederImplementation : XBaseDbSeeder<XSubCategory, int>
|
||||
{
|
||||
//
|
||||
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<TSeederImplementation>()
|
||||
where TSeederImplementation : XBaseDbSeeder<XSubCategory, int>
|
||||
{
|
||||
//
|
||||
var result = new XInMemoryRepositoryDescriptor<
|
||||
XSubCategory,
|
||||
int,
|
||||
IXSubCategoryKeyGenerator,
|
||||
XSubCategoryKeyGenerator,
|
||||
IXSubCategoryRepositoryEvents,
|
||||
XSubCategoryRepositoryEvents,
|
||||
XSubCategoryGraphType,
|
||||
IntGraphType,
|
||||
XSubCategoryGraphQuery,
|
||||
IXSubCategoryGraphQLTypeHelper,
|
||||
XSubCategoryGraphQLTypeHelper,
|
||||
XSubCategoryGraphSchema,
|
||||
IXSubCategoryRepository,
|
||||
XSubCategoryInMemoryRepository,
|
||||
IXSubCategorySeeder,
|
||||
TSeederImplementation
|
||||
>();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using xCategoryService.Models.Dtos;
|
||||
using xCategoryService.Models.Entities;
|
||||
using xPushService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces.Dtos
|
||||
{
|
||||
public interface IXSubCategoryDtoHub : IXBaseDtoHub<XSubCategory, XSubCategoryDto, int>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using xCategoryService.Models.Dtos;
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces.Dtos
|
||||
{
|
||||
public interface IXSubCategoryRepositoryService : IXBaseRepositoryService<XSubCategory, XSubCategoryDto, int>
|
||||
{ }
|
||||
}
|
||||
@@ -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<XSubCategory, XSubCategoryDto, int, XSubCategoryDtoHub>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using xCategoryService.Models.Entities;
|
||||
using xPushService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces.Entities
|
||||
{
|
||||
public interface IXSubCategoryEntityHub : IXBaseEntityHub<XSubCategory, int>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces.Entities
|
||||
{
|
||||
public interface IXSubCategoryGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XSubCategory, int>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces.Entities
|
||||
{
|
||||
public interface IXSubCategoryKeyGenerator : IXKeyGenerator<XSubCategory, int>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces.Entities
|
||||
{
|
||||
public interface IXSubCategoryRepository : IXBaseRepository<XSubCategory, int>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces.Entities
|
||||
{
|
||||
public interface IXSubCategoryRepositoryEvents : IXBaseRepositoryEvents<XSubCategory>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using xCategoryService.Models.Entities;
|
||||
using xCategoryService.Providers.Entities;
|
||||
using xPushService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces.Entities
|
||||
{
|
||||
public interface IXSubCategoryRepositoryProvider : IXBaseEntityProvider<XSubCategory, int, XSubCategoryEntityHub>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using xStringService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces
|
||||
{
|
||||
public interface IXSubCategoryDescriptionResourceProvider : IXItemResourceProvider
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.Interfaces;
|
||||
|
||||
namespace xCategoryService.Interfaces
|
||||
{
|
||||
public interface IXSubCategorySeeder : IXBaseDbSeeder<XSubCategory, int>
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using xModels.Base;
|
||||
|
||||
namespace xCategoryService.Models.Dtos
|
||||
{
|
||||
public class XSubCategoryDto : XBaseIntIDEntityDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Title of SubCategory ...
|
||||
/// this is a Resource Title ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Description of SubCategory ...
|
||||
/// this is a Resource Title ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// References List String Representation ...
|
||||
/// each SubCategory Referenced to Category ID which List here ...
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string References { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, XSubCategoryDto, int>, IXSubCategoryDtoHub
|
||||
{
|
||||
public XSubCategoryDtoHub(
|
||||
ILogger<XSubCategoryDtoHub> logger
|
||||
) : base(logger)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, XSubCategoryDto, int>, IXSubCategoryRepositoryService
|
||||
{
|
||||
public XSubCategoryRepositoryService(
|
||||
IXSubCategoryRepository repository,
|
||||
IEnumerable<Profile> mapperProfiles = null
|
||||
) : base(
|
||||
repository,
|
||||
mapperProfiles
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, XSubCategoryDto, int, XSubCategoryDtoHub>, IXSubCategoryServiceProvider
|
||||
{
|
||||
public XSubCategoryServiceProvider(
|
||||
IHubContext<XSubCategoryDtoHub> hub,
|
||||
XDataServiceConfiguration dataConfiguration,
|
||||
IXSubCategoryRepositoryService service,
|
||||
IXIdentityProvider identityProvider = null
|
||||
) : base(
|
||||
hub,
|
||||
dataConfiguration,
|
||||
service,
|
||||
identityProvider
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<TContext> : XBaseEFRepository<XSubCategory, int, TContext>, IXSubCategoryRepository
|
||||
where TContext : XDbContext
|
||||
{
|
||||
public XSubCategoryEFRepository(
|
||||
IXUnitOfWorks<TContext> unitOfWorks,
|
||||
XDataServiceConfiguration configuration,
|
||||
IXSubCategoryKeyGenerator keyGenerator = null,
|
||||
IXSubCategoryRepositoryEvents baseRepositoryEvents = null
|
||||
) : base(
|
||||
unitOfWorks,
|
||||
configuration,
|
||||
keyGenerator,
|
||||
baseRepositoryEvents
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, int>, IXSubCategoryEntityHub
|
||||
{
|
||||
public XSubCategoryEntityHub(
|
||||
ILogger<XSubCategoryEntityHub> logger
|
||||
) : base(logger)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, int>, IXSubCategoryRepository
|
||||
{
|
||||
public XSubCategoryInMemoryRepository(
|
||||
XDataServiceConfiguration configuration,
|
||||
IXSubCategoryKeyGenerator keyGenerator = null,
|
||||
IXSubCategoryRepositoryEvents baseRepositoryEvents = null
|
||||
) : base(
|
||||
configuration,
|
||||
keyGenerator,
|
||||
baseRepositoryEvents
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using xCategoryService.Interfaces.Entities;
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.Providers;
|
||||
|
||||
namespace xCategoryService.Providers.Entities
|
||||
{
|
||||
public class XSubCategoryKeyGenerator : XIntKeyGenerator<XSubCategory>, IXSubCategoryKeyGenerator
|
||||
{ }
|
||||
}
|
||||
@@ -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<XSubCategory, int>, IXSubCategoryRepository
|
||||
{
|
||||
public XSubCategoryMongoRepository(
|
||||
XDataBaseConfiguration dbConfiguration,
|
||||
XDataServiceConfiguration configuration,
|
||||
string collectionName = null,
|
||||
IXSubCategoryKeyGenerator keyGenerator = null,
|
||||
IXSubCategoryRepositoryEvents baseRepositoryEvents = null
|
||||
) : base(
|
||||
dbConfiguration,
|
||||
configuration,
|
||||
collectionName,
|
||||
keyGenerator,
|
||||
baseRepositoryEvents
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using xCategoryService.Interfaces.Entities;
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.Providers;
|
||||
|
||||
namespace xCategoryService.Providers.Entities
|
||||
{
|
||||
public class XSubCategoryRepositoryEvents : XBaseRepositoryEvents<XSubCategory>, IXSubCategoryRepositoryEvents
|
||||
{ }
|
||||
}
|
||||
@@ -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<XSubCategory, int, XSubCategoryEntityHub>, IXSubCategoryRepositoryProvider
|
||||
{
|
||||
public XSubCategoryRepositoryProvider(
|
||||
IHubContext<XSubCategoryEntityHub> hub,
|
||||
IXSubCategoryRepository repository,
|
||||
XDataServiceConfiguration dataConfiguration,
|
||||
IXIdentityProvider identityProvider = null
|
||||
) : base(
|
||||
hub,
|
||||
repository,
|
||||
dataConfiguration,
|
||||
identityProvider
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, int>, IXSubCategoryGraphQLTypeHelper
|
||||
{
|
||||
public XSubCategoryGraphQLTypeHelper(
|
||||
XDataServiceConfiguration configuration
|
||||
) : base(configuration)
|
||||
{ }
|
||||
|
||||
public override string GetInQueryCollectionName()
|
||||
{
|
||||
return "subCategories";
|
||||
}
|
||||
|
||||
public override string GetInQuerySingleName()
|
||||
{
|
||||
return "subCategory";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, int, XSubCategoryGraphType, IntGraphType>
|
||||
{
|
||||
public XSubCategoryGraphQuery(
|
||||
XDataServiceConfiguration configuration,
|
||||
IXSubCategoryRepository repository,
|
||||
IXSubCategoryGraphQLTypeHelper helper
|
||||
) : base(
|
||||
configuration,
|
||||
repository,
|
||||
helper
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using xCategoryService.Models.Entities;
|
||||
using xDataService.GraphQL;
|
||||
|
||||
namespace xCategoryService.Providers.GraphQL
|
||||
{
|
||||
public class XSubCategoryGraphType : XBaseGraphObjectType<XSubCategory, int>
|
||||
{
|
||||
public XSubCategoryGraphType() : base()
|
||||
{
|
||||
Field(x => x.Title);
|
||||
Field(x => x.Description);
|
||||
Field(x => x.References);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, int>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configure Entities ...
|
||||
/// </summary>
|
||||
/// <param name="modelBuilder"></param>
|
||||
public override void ConfigureEntities(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.ConfigureEntities(modelBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<XSubCategory, int>, IXSubCategorySeeder
|
||||
{
|
||||
protected XSubCategorySeederBase(
|
||||
string entity,
|
||||
string database,
|
||||
IXSubCategoryRepository repository,
|
||||
XDataServiceConfiguration dataServiceConfiguration
|
||||
) : base(
|
||||
entity,
|
||||
database,
|
||||
repository,
|
||||
dataServiceConfiguration
|
||||
)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user