adding Data Requirement on XContent Service ...

This commit is contained in:
2026-08-18 14:05:36 +03:30
parent 71fd4cea74
commit 0daa339d12
34 changed files with 1009 additions and 1 deletions
@@ -0,0 +1,17 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using xContentService.Constants;
using xContentService.Models.Entities;
using xDataService.Providers;
namespace xContentService.Configuration.Entities
{
public class XContentEntityConfiguration : XBaseEntityTypeConfiguration<XContent, Guid>
{
public override void Configure(EntityTypeBuilder<XContent> builder)
{
builder.ToTable(XContentServiceConstants.XContentTable);
}
}
}
+4
View File
@@ -19,5 +19,9 @@ namespace xContentService.Constants
// Hubs ... // Hubs ...
public const string XContentDtoHub = "contentDto"; public const string XContentDtoHub = "contentDto";
public const string XContentEntityHub = "contentEntity"; public const string XContentEntityHub = "contentEntity";
//
// EF Repositories Helper Extensions ...
public const string GetXContentEFRepositoryDescriptor = "GetXContentEFRepositoryDescriptor";
} }
} }
+237
View File
@@ -0,0 +1,237 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using xCommons.Extensions;
using xContentService.Constants;
using xContentService.Providers.Dtos;
using xContentService.Providers.Entities;
using xDataService.Constants;
using xDataService.Models;
using xPushService.DI;
using xDataService.DI;
using xPushService.Helpers;
using System;
using xExceptions.Constants;
using xContentService.Helpers;
using xCommons.Helpers;
using xContentService.Interfaces.Dtos;
using xContentService.Interfaces.Entities;
using xDataService.Db;
namespace xContentService.DI
{
/// <summary>
/// Service Registration Extensions Classes ...
/// </summary>
public static partial class XDIHelperExtensions
{
/// <summary>
/// Register Service ...
/// </summary>
/// <param name="services"></param>
/// <param name="repositoryType"></param>
/// <param name="lifeTime"></param>
public static void AddXContentService(
this IServiceCollection services,
XRepositoryType repositoryType,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
)
{
AddContentService(
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 AddXContentService<TContext>(
this IServiceCollection services,
XRepositoryType repositoryType,
ServiceLifetime lifeTime = ServiceLifetime.Scoped
)
where TContext : XDbContext
{
AddContentService(
services: services,
lifeTime: lifeTime,
contextType: typeof(TContext),
repositoryType: repositoryType
);
}
/// <summary>
/// Use xContentService Middleware ...
/// </summary>
/// <param name="app"></param>
/// <param name="isDevelopmentEnvironment"></param>
public static void UseXContentService(
this IApplicationBuilder app,
bool isDevelopmentEnvironment = false
)
{
//
#region Using XContent Hubs ...
//
var pushHelper = new XPushServiceHelper();
//
pushHelper.AddHub<XContentDtoHub>(XContentServiceConstants.XContentDtoHub);
pushHelper.AddHub<XContentEntityHub>(XContentServiceConstants.XContentEntityHub);
//
app.UseXPushService(pushHelper);
#endregion
//
// Using XContent Repository Descriptor ...
if (!descriptor.IsNull())
{
//
app.UseXRepository(
descriptor: descriptor,
isDevelopmentEnvironment: isDevelopmentEnvironment
);
}
}
//
#region Private ...
private static XRepositoryDescriptor descriptor = null;
/// <summary>
/// a LogTag for Service ...
/// </summary>
private static string XLogTag = XContentServiceConstants.XContentServiceDILogTag;
/// <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 AddContentService(
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:
//
descriptor = typeof(XContentServiceHelper)
.InvokeGenericMethod<XRepositoryDescriptor>(
args: null,
runtimeType: contextType,
methodName: XContentServiceConstants.GetXContentEFRepositoryDescriptor
);
break;
//
case XRepositoryType.Mongo:
descriptor = XContentServiceHelper.GetXContentMongoRepositoryDescriptor();
break;
//
case XRepositoryType.InMemory:
descriptor = XContentServiceHelper.GetXContentInMemoryRepositoryDescriptor();
break;
}
//
// Register XContent Repository Descriptor ...
services.AddXRepository(
lifeTime: lifeTime,
descriptor: descriptor
);
//
// Register Dto Services ...
services.Add(
new ServiceDescriptor(typeof(IXContentServiceProvider), typeof(XContentServiceProvider), lifeTime)
);
services.Add(
new ServiceDescriptor(typeof(IXContentRepositoryService), typeof(XContentRepositoryService), lifeTime)
);
services.Add(
new ServiceDescriptor(typeof(IXContentRepositoryProvider), typeof(XContentRepositoryProvider), lifeTime)
);
//
// Register Additional Service ...
// services.Add(
// new ServiceDescriptor(typeof(IXContentTagProvider), typeof(XContentTagProvider), lifeTime)
// );
// services.Add(
// new ServiceDescriptor(typeof(IXContentTagProvided), typeof(XContentTagProvided), lifeTime)
// );
// services.Add(
// new ServiceDescriptor(typeof(IXContentProvider), typeof(XContentProvider), lifeTime)
// );
//
Log("Service Regitration Succeed ...");
}
#endregion
}
}
+282
View File
@@ -0,0 +1,282 @@
using System;
using GraphQL.Types;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xContentService.Providers.Entities;
using xContentService.Providers.GraphQL;
using xDataService.Db;
using xDataService.Models;
using xDataService.Providers;
namespace xContentService.Helpers
{
public static class XContentServiceHelper
{
//
#region XContent ...
//
#region EF Repository Descriptor Provider(s) ...
public static XEFRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentEFRepository<TContext>,
TContext
> GetXContentEFRepositoryDescriptor<TContext>()
where TContext : XDbContext
{
//
var result = new XEFRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentEFRepository<TContext>,
TContext
>();
//
return result;
}
public static XEFRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentEFRepository<TContext>,
TContext,
IXContentSeeder,
TSeederImplementation
> GetXContentEFRepositoryDescriptor<TContext, TSeederImplementation>()
where TContext : XDbContext
where TSeederImplementation : XBaseDbSeeder<XContent, Guid>
{
//
var result = new XEFRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentEFRepository<TContext>,
TContext,
IXContentSeeder,
TSeederImplementation
>();
//
return result;
}
#endregion
//
#region Mongo Repository Descriptor Provider(s) ...
public static XMongoRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentMongoRepository
> GetXContentMongoRepositoryDescriptor()
{
//
var result = new XMongoRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentMongoRepository
>();
//
return result;
}
public static XMongoRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentMongoRepository,
IXContentSeeder,
TSeederImplementation
> GetXContentMongoRepositoryDescriptor<TSeederImplementation>()
where TSeederImplementation : XBaseDbSeeder<XContent, Guid>
{
//
var result = new XMongoRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentMongoRepository,
IXContentSeeder,
TSeederImplementation
>();
//
return result;
}
#endregion
//
#region InMemory Repository Descriptor Provider(s) ...
public static XInMemoryRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentInMemoryRepository
> GetXContentInMemoryRepositoryDescriptor()
{
//
var result = new XInMemoryRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentInMemoryRepository
>();
//
return result;
}
public static XInMemoryRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentInMemoryRepository,
IXContentSeeder,
TSeederImplementation
> GetXContentInMemoryRepositoryDescriptor<TSeederImplementation>()
where TSeederImplementation : XBaseDbSeeder<XContent, Guid>
{
//
var result = new XInMemoryRepositoryDescriptor<
XContent,
Guid,
IXContentKeyGenerator,
XContentKeyGenerator,
IXContentRepositoryEvents,
XContentRepositoryEvents,
XContentGraphType,
GuidGraphType,
XContentGraphQuery,
IXContentGraphQLTypeHelper,
XContentGraphQLTypeHelper,
XContentGraphSchema,
IXContentRepository,
XContentInMemoryRepository,
IXContentSeeder,
TSeederImplementation
>();
//
return result;
}
#endregion
#endregion
}
}
+10
View File
@@ -0,0 +1,10 @@
using System;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xPushService.Interfaces;
namespace xContentService.Interfaces.Dtos
{
public interface IXContentDtoHub : IXBaseDtoHub<XContent, XContentDto, Guid>
{ }
}
@@ -0,0 +1,10 @@
using System;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xDataService.Interfaces;
namespace xContentService.Interfaces.Dtos
{
public interface IXContentRepositoryService : IXBaseRepositoryService<XContent, XContentDto, Guid>
{ }
}
@@ -0,0 +1,11 @@
using System;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xContentService.Providers.Dtos;
using xPushService.Interfaces;
namespace xContentService.Interfaces.Dtos
{
public interface IXContentServiceProvider : IXBaseDtoProvider<XContent, XContentDto, Guid, XContentDtoHub>
{ }
}
@@ -0,0 +1,6 @@
namespace xContentService.Interfaces.Enrichers
{
// TODO: Complete this ...
public interface IXContentEnricher
{ }
}
@@ -0,0 +1,9 @@
using System;
using xContentService.Models.Entities;
using xPushService.Interfaces;
namespace xContentService.Interfaces.Entities
{
public interface IXContentEntityHub : IXBaseEntityHub<XContent, Guid>
{ }
}
@@ -0,0 +1,9 @@
using System;
using xContentService.Models.Entities;
using xDataService.Interfaces;
namespace xContentService.Interfaces.Entities
{
public interface IXContentGraphQLTypeHelper : IXBaseGraphQLTypeHelper<XContent, Guid>
{ }
}
@@ -0,0 +1,9 @@
using System;
using xContentService.Models.Entities;
using xDataService.Interfaces;
namespace xContentService.Interfaces.Entities
{
public interface IXContentKeyGenerator : IXKeyGenerator<XContent, Guid>
{ }
}
@@ -0,0 +1,9 @@
using System;
using xContentService.Models.Entities;
using xDataService.Interfaces;
namespace xContentService.Interfaces.Entities
{
public interface IXContentRepository : IXBaseRepository<XContent, Guid>
{ }
}
@@ -0,0 +1,8 @@
using xContentService.Models.Entities;
using xDataService.Interfaces;
namespace xContentService.Interfaces.Entities
{
public interface IXContentRepositoryEvents : IXBaseRepositoryEvents<XContent>
{ }
}
@@ -0,0 +1,10 @@
using System;
using xContentService.Models.Entities;
using xContentService.Providers.Entities;
using xPushService.Interfaces;
namespace xContentService.Interfaces.Entities
{
public interface IXContentRepositoryProvider : IXBaseEntityProvider<XContent, Guid, XContentEntityHub>
{ }
}
+9
View File
@@ -0,0 +1,9 @@
using System;
using xContentService.Models.Entities;
using xDataService.Interfaces;
namespace xContentService.Interfaces.Entities
{
public interface IXContentSeeder : IXBaseDbSeeder<XContent, Guid>
{ }
}
+18 -1
View File
@@ -1,7 +1,24 @@
using System;
using xModels.Base;
using xModels.Dtos;
namespace xContentService.Models.Dtos namespace xContentService.Models.Dtos
{ {
public class XContentDto /// <summary>
/// Content Describe DTO ...
/// </summary>
public class XContentDto : XBaseGuidIDEntityDto
{ {
public string OwnerId { get; set; }
public virtual XPersonDto Owner { get; set; }
public string Title { get; set; }
public virtual XResourceDto TitleResource { get; set; }
public string Description { get; set; }
public virtual XResourceDto DescriptionResource { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime UpdatedAt { get; set; }
} }
} }
+2
View File
@@ -1,3 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using xModels.Base; using xModels.Base;
namespace xContentService.Models.Entities namespace xContentService.Models.Entities
+17
View File
@@ -0,0 +1,17 @@
using System;
using Microsoft.Extensions.Logging;
using xContentService.Interfaces.Dtos;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xPushService.Base;
namespace xContentService.Providers.Dtos
{
public class XContentDtoHub : XBaseDtoHub<XContent, XContentDto, Guid>, IXContentDtoHub
{
public XContentDtoHub(
ILogger<XContentDtoHub> logger
) : base(logger)
{ }
}
}
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using AutoMapper;
using xContentService.Interfaces.Dtos;
using xContentService.Interfaces.Entities;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xDataService.Providers;
namespace xContentService.Providers.Dtos
{
public class XContentRepositoryService : XBaseRepositoryService<XContent, XContentDto, Guid>, IXContentRepositoryService
{
public XContentRepositoryService(
IXContentRepository repository,
IEnumerable<Profile> mapperProfiles = null
) : base(
repository,
mapperProfiles
)
{ }
//
// TODO: Implement Enrichers ...
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
using Microsoft.AspNetCore.SignalR;
using xContentService.Interfaces.Dtos;
using xContentService.Models.Dtos;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xIdentityService.Interfaces;
using xPushService.Base;
namespace xContentService.Providers.Dtos
{
public class XContentServiceProvider : XBaseDtoProvider<XContent, XContentDto, Guid, XContentDtoHub>, IXContentServiceProvider
{
public XContentServiceProvider(
IHubContext<XContentDtoHub> hub,
XDataServiceConfiguration dataConfiguration,
IXContentRepositoryService service,
IXIdentityProvider identityProvider = null
) : base(
hub,
dataConfiguration,
service,
identityProvider
)
{ }
}
}
+10
View File
@@ -0,0 +1,10 @@
using xContentService.Interfaces.Enrichers;
namespace xContentService.Providers.Enrichers
{
public class XContentEnricher : IXContentEnricher
{
//
// TODO: Complete this ...
}
}
@@ -0,0 +1,27 @@
using System;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.Db;
using xDataService.Interfaces;
using xDataService.Providers;
namespace xContentService.Providers.Entities
{
public class XContentEFRepository<TContext> : XBaseEFRepository<XContent, Guid, TContext>, IXContentRepository
where TContext : XDbContext
{
public XContentEFRepository(
IXUnitOfWorks<TContext> unitOfWorks,
XDataServiceConfiguration configuration,
IXContentKeyGenerator keyGenerator = null,
IXContentRepositoryEvents baseRepositoryEvents = null
) : base(
unitOfWorks,
configuration,
keyGenerator,
baseRepositoryEvents
)
{ }
}
}
+16
View File
@@ -0,0 +1,16 @@
using System;
using Microsoft.Extensions.Logging;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xPushService.Base;
namespace xContentService.Providers.Entities
{
public class XContentEntityHub : XBaseEntityHub<XContent, Guid>, IXContentEntityHub
{
public XContentEntityHub(
ILogger<XContentEntityHub> logger
) : base(logger)
{ }
}
}
@@ -0,0 +1,22 @@
using System;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.Providers;
namespace xContentService.Providers.Entities
{
public class XContentInMemoryRepository : XBaseInMemoryRepository<XContent, Guid>, IXContentRepository
{
public XContentInMemoryRepository(
XDataServiceConfiguration configuration,
IXContentKeyGenerator keyGenerator = null,
IXContentRepositoryEvents baseRepositoryEvents = null
) : base(
configuration,
keyGenerator,
baseRepositoryEvents
)
{ }
}
}
@@ -0,0 +1,9 @@
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Providers;
namespace xContentService.Providers.Entities
{
public class XContentKeyGenerator : XGuidKeyGenerator<XContent>, IXContentKeyGenerator
{ }
}
@@ -0,0 +1,26 @@
using System;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.Providers;
namespace xContentService.Providers.Entities
{
public class XContentMongoRepository : XBaseMongoRepository<XContent, Guid>, IXContentRepository
{
public XContentMongoRepository(
XDataBaseConfiguration dbConfiguration,
XDataServiceConfiguration configuration,
string collectionName = null,
IXContentKeyGenerator keyGenerator = null,
IXContentRepositoryEvents baseRepositoryEvents = null
) : base(
dbConfiguration,
configuration,
collectionName,
keyGenerator,
baseRepositoryEvents
)
{ }
}
}
@@ -0,0 +1,9 @@
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Providers;
namespace xContentService.Providers.Entities
{
public class XContentRepositoryEvents : XBaseRepositoryEvents<XContent>, IXContentRepositoryEvents
{ }
}
@@ -0,0 +1,26 @@
using System;
using Microsoft.AspNetCore.SignalR;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xIdentityService.Interfaces;
using xPushService.Base;
namespace xContentService.Providers.Entities
{
public class XContentRepositoryProvider : XBaseEntityProvider<XContent, Guid, XContentEntityHub>, IXContentRepositoryProvider
{
public XContentRepositoryProvider(
IHubContext<XContentEntityHub> hub,
IXContentRepository repository,
XDataServiceConfiguration dataConfiguration,
IXIdentityProvider identityProvider = null
) : base(
hub,
repository,
dataConfiguration,
identityProvider
)
{ }
}
}
+24
View File
@@ -0,0 +1,24 @@
using System;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.Providers;
namespace xContentService.Providers.Entities
{
public abstract class XContentSeederBase : XBaseDbSeeder<XContent, Guid>, IXContentSeeder
{
protected XContentSeederBase(
string entity,
string database,
IXContentRepository repository,
XDataServiceConfiguration dataServiceConfiguration
) : base(
entity,
database,
repository,
dataServiceConfiguration
)
{ }
}
}
@@ -0,0 +1,21 @@
using System;
using xContentService.Constants;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.GraphQL;
namespace xContentService.Providers.GraphQL
{
public class XContentGraphQLTypeHelper : XBaseGraphQLTypeHelper<XContent, Guid>, IXContentGraphQLTypeHelper
{
public override string GetInQueryCollectionName()
{
return XContentServiceConstants.XContentCollectionName;
}
public override string GetInQuerySingleName()
{
return XContentServiceConstants.XContentSingleName;
}
}
}
+23
View File
@@ -0,0 +1,23 @@
using System;
using GraphQL.Types;
using xContentService.Interfaces.Entities;
using xContentService.Models.Entities;
using xDataService.Configuration;
using xDataService.GraphQL;
namespace xContentService.Providers.GraphQL
{
public class XContentGraphQuery : XBaseGraphQLQuery<XContent, Guid, XContentGraphType, GuidGraphType>
{
public XContentGraphQuery(
XDataServiceConfiguration configuration,
IXContentRepository repository,
IXContentGraphQLTypeHelper helper
) : base(
configuration,
repository,
helper
)
{ }
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using GraphQL.Types;
namespace xContentService.Providers.GraphQL
{
public class XContentGraphSchema : Schema
{
public XContentGraphSchema(IServiceProvider services) : base(services)
{
Query = (XContentGraphQuery)services.GetService(typeof(XContentGraphQuery));
}
}
}
+18
View File
@@ -0,0 +1,18 @@
using System;
using xContentService.Models.Entities;
using xDataService.GraphQL;
namespace xContentService.Providers.GraphQL
{
public class XContentGraphType : XBaseGraphObjectType<XContent, Guid>
{
public XContentGraphType() : base()
{
Field(x => x.Title);
Field(x => x.OwnerId);
Field(x => x.CreatedOn);
Field(x => x.UpdatedAt);
Field(x => x.Description);
}
}
}
+35
View File
@@ -0,0 +1,35 @@
using System;
using Microsoft.EntityFrameworkCore;
using xContentService.Configuration.Entities;
using xContentService.Models.Entities;
using xDataService.Interfaces;
using xDataService.Providers;
namespace xContentService.Providers
{
public class XContentEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
{
public XContentEntityRegisterar()
: base(nameof(XContentEntityRegisterar))
{
//
// Add Entity ...
AddEntity<XContent, Guid>();
}
/// <summary>
/// Configure Entities ...
/// </summary>
/// <param name="modelBuilder"></param>
public override void ConfigureEntities(ModelBuilder modelBuilder)
{
//
// Configure Entity Using Provided ...
modelBuilder
.ApplyConfigurationsFromAssembly(typeof(XContentEntityConfiguration).Assembly);
//
base.ConfigureEntities(modelBuilder);
}
}
}