### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Configuration\Entities\XContentEntityConfiguration.cs using System; using xDataService.Providers; using xContentService.Constants; using Microsoft.EntityFrameworkCore; using xContentService.Models.Entities; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace xContentService.Configuration.Entities { public class XContentEntityConfiguration : XBaseEntityTypeConfiguration { public override void Configure(EntityTypeBuilder builder) { builder.ToTable(XContentServiceConstants.XContentTable); } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Constants\XContentServiceConstants.cs using xContentService.Models.Entities; namespace xContentService.Constants { public struct XContentServiceConstants { // // Service Extensions Log Tag ... public const string XContentServiceDILogTag = "XContentService"; // // Table Mapping Identifiers ... public const string XContentTable = "Contents"; // // GraphQL Collection Mappings ... public const string XContentSingleName = "content"; public const string XContentCollectionName = "contents"; // // Hubs ... public const string XContentDtoHub = "contentDto"; public const string XContentEntityHub = "contentEntity"; // // EF Repositories Helper Extensions ... public const string GetXContentEFRepositoryDescriptor = "GetXContentEFRepositoryDescriptor"; // // Custome Constants ... public const string XAdminRole = "admin"; public const string XContentTagProvided = nameof(XContent); public const string XContentTitleIdentifier = "CntnT"; public const string XContentDescriptionIdentifier = "CntnD"; } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Controllers\XContentRepositoryControllerBase.cs using System; using System.Linq; using xCommons.Providers; using xCommons.Configurations; using xDataService.Interfaces; using xDataService.Controllers; using Microsoft.Extensions.Logging; using xContentService.Models.Entities; using Microsoft.EntityFrameworkCore.Query; using xContentService.Interfaces.Entities; namespace xContentService.Controllers { public abstract class XContentRepositoryControllerBase : XBaseRepositoryController, IXBaseRepositoryController { protected XContentRepositoryControllerBase( ILogger logger, XAppConfiguration appConfiguration, XValidationProvider validationProvider, IXContentRepository repository, Func, IOrderedQueryable> defaultOrderBuilder = null, Func, IIncludableQueryable> defaultIncludeBuilder = null ) : base( logger, appConfiguration, validationProvider, repository, defaultOrderBuilder, defaultIncludeBuilder ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Controllers\XContentRepositoryProviderControllerBase.cs using System; using System.Linq; using xCommons.Providers; using xPushService.Interfaces; using xCommons.Configurations; using xPushService.Controllers; using xIdentityService.Interfaces; using Microsoft.Extensions.Logging; using xContentService.Models.Entities; using xContentService.Providers.Entities; using Microsoft.EntityFrameworkCore.Query; using xContentService.Interfaces.Entities; namespace xContentService.Controllers { public abstract class XContentRepositoryProviderControllerBase : XBaseRepositoryProviderController, IXBaseRepositoryProviderController { protected XContentRepositoryProviderControllerBase( ILogger logger, XAppConfiguration appConfiguration, IXIdentityProvider identityProvider, XValidationProvider validationProvider, IXContentRepositoryProvider provider, Func, IOrderedQueryable> defaultOrderBuilder = null, Func, IIncludableQueryable> defaultIncludeBuilder = null ) : base( logger, appConfiguration, identityProvider, validationProvider, provider, defaultOrderBuilder, defaultIncludeBuilder ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Controllers\XContentServiceControllerBase.cs using System; using System.Linq; using xCommons.Providers; using xCommons.Configurations; using xDataService.Interfaces; using xDataService.Controllers; using xContentService.Models.Dtos; using Microsoft.Extensions.Logging; using xContentService.Models.Entities; using xContentService.Interfaces.Dtos; using Microsoft.EntityFrameworkCore.Query; namespace xContentService.Controllers { public abstract class XContentServiceControllerBase : XBaseServiceController, IXBaseServiceController { protected XContentServiceControllerBase( ILogger logger, XAppConfiguration appConfiguration, XValidationProvider validationProvider, IXContentRepositoryService repositoryService, Func, IOrderedQueryable> defaultOrderBuilder = null, Func, IIncludableQueryable> defaultIncludeBuilder = null ) : base( logger, appConfiguration, validationProvider, repositoryService, defaultOrderBuilder, defaultIncludeBuilder ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Controllers\XContentServiceProviderControllerBase.cs using System; using System.Linq; using xCommons.Providers; using xCommons.Configurations; using xPushService.Interfaces; using xPushService.Controllers; using xContentService.Models.Dtos; using xIdentityService.Interfaces; using Microsoft.Extensions.Logging; using xContentService.Providers.Dtos; using xContentService.Models.Entities; using xContentService.Interfaces.Dtos; using Microsoft.EntityFrameworkCore.Query; namespace xContentService.Controllers { public abstract class XContentServiceProviderControllerBase : XBaseServiceProviderController, IXBaseServiceProviderController { protected XContentServiceProviderControllerBase( ILogger logger, XAppConfiguration appConfiguration, IXIdentityProvider identityProvider, XValidationProvider validationProvider, IXContentServiceProvider provider, Func, IOrderedQueryable> defaultOrderBuilder = null, Func, IIncludableQueryable> defaultIncludeBuilder = null ) : base( logger, appConfiguration, identityProvider, validationProvider, provider, defaultOrderBuilder, defaultIncludeBuilder ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Controllers\XControllerProviderControllerBase.cs using System; using System.Linq; using System.Threading; using xCommons.Providers; using xCommons.Extensions; using xExceptions.Constants; using System.Threading.Tasks; using xCommons.Configurations; using xTagService.Controllers; using Microsoft.AspNetCore.Mvc; using xContentService.Interfaces; using xContentService.Models.Dtos; using xIdentityService.Interfaces; using Microsoft.Extensions.Logging; using xContentService.Providers.Dtos; using xContentService.Models.Entities; using Microsoft.EntityFrameworkCore.Query; using xContentService.Interfaces.Controllers; namespace xContentService.Controllers { public abstract class XContentProviderControllerBase : XBaseProvidedHasTagControllerBase, IXContentProviderController { private readonly IXContentProvider provider; protected XContentProviderControllerBase( ILogger> logger, XAppConfiguration appConfiguration, IXIdentityProvider identityProvider, XValidationProvider validationProvider, IXContentProvider provider, IXContentTagProvided tagProvided, Func, IOrderedQueryable> defaultOrderBuilder = null, Func, IIncludableQueryable> defaultIncludeBuilder = null ) : base( logger, appConfiguration, identityProvider, validationProvider, provider, tagProvided, defaultOrderBuilder, defaultIncludeBuilder ) { this.provider = provider; } /// /// Add an item ... /// /// /// /// /// [HttpPost("Add")] public async Task> Add( [FromBody] XContentDto item, [FromQuery] string language = null, CancellationToken cancellationToken = default ) { // try { // // Validate ... if (!ModelState.IsValid) { XException.InvalidArgs.Throw(); } await ValidationProvider .GroupValidationBuilder() .AddNotNull(item) .AddNotEmpty(item.Title) .ValidateGroupAsync(); // var userInfo = await GetUserInfo(); var connectionId = GetConnectionId(); // // Normalize Language ... if (language.IsNullOrEmpty()) { language = AppConfiguration.DefaultLanguage; } if (language.IsNullOrEmpty()) { XException.InvalidData.Throw(); } // var result = await provider.Add( item: item, userInfo: userInfo, language: language, connectionId: connectionId, cancellationToken: cancellationToken ); // return result; } catch (Exception ex) { // var result = GetExceptionActionResult(ex); return result; } } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\DI\XDIHelperExtensions.cs using System; using xPushService.DI; using xDataService.DI; using xDataService.Db; using xCommons.Helpers; using xDataService.Models; using xCommons.Extensions; using xPushService.Helpers; using xExceptions.Constants; using xDataService.Constants; using xContentService.Helpers; using xContentService.Constants; using xContentService.Providers; using xContentService.Interfaces; using Microsoft.AspNetCore.Builder; using xContentService.Providers.Dtos; using xContentService.Interfaces.Dtos; using xContentService.Providers.Entities; using xContentService.Interfaces.Entities; using xContentService.Providers.Enrichers; using xContentService.Interfaces.Enrichers; using Microsoft.Extensions.DependencyInjection; namespace xContentService.DI { /// /// Service Registration Extensions Classes ... /// public static partial class XDIHelperExtensions { /// /// Register Service ... /// /// /// /// public static void AddXContentService( this IServiceCollection services, XRepositoryType repositoryType, ServiceLifetime lifeTime = ServiceLifetime.Scoped ) { AddContentService( contextType: null, services: services, lifeTime: lifeTime, repositoryType: repositoryType ); } /// /// Register Service ... /// /// /// /// /// public static void AddXContentService( this IServiceCollection services, XRepositoryType repositoryType, ServiceLifetime lifeTime = ServiceLifetime.Scoped ) where TContext : XDbContext { AddContentService( services: services, lifeTime: lifeTime, contextType: typeof(TContext), repositoryType: repositoryType ); } /// /// Use xContentService Middleware ... /// /// /// public static void UseXContentService( this IApplicationBuilder app, bool isDevelopmentEnvironment = false ) { // #region Using XContent Hubs ... // var pushHelper = new XPushServiceHelper(); // pushHelper.AddHub(XContentServiceConstants.XContentDtoHub); pushHelper.AddHub(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; /// /// a LogTag for Service ... /// private static string XLogTag = XContentServiceConstants.XContentServiceDILogTag; /// /// print a log in Console ... /// /// private static void Log(string message) { Console.WriteLine($"{XLogTag} => {message}"); } /// /// Register Service ... /// /// /// /// /// 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( 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 ); // // Resource Providers ... services.Add( new ServiceDescriptor(typeof(IXContentTitleResourceProvider), typeof(XContentTitleResourceProvider), lifeTime) ); services.Add( new ServiceDescriptor(typeof(IXContentDescriptionResourceProvider), typeof(XContentDescriptionResourceProvider), lifeTime) ); // // Enrichers ... services.Add( new ServiceDescriptor(typeof(IXContentEnricher), typeof(XContentEnricher), lifeTime) ); // // 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) ); // // Tags ... services.Add( new ServiceDescriptor(typeof(IXContentTagProvider), typeof(XContentTagProvider), lifeTime) ); services.Add( new ServiceDescriptor(typeof(IXContentTagProvided), typeof(XContentTagProvided), lifeTime) ); // // Provider ... services.Add( new ServiceDescriptor(typeof(IXContentProvider), typeof(XContentProvider), lifeTime) ); // Log("Service Regitration Succeed ..."); } #endregion } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Extensions\XModelExtensions.cs using xCommons.Extensions; using xContentService.Models.Dtos; using xContentService.Models.Entities; namespace xContentService.Extensions { /// /// All Service Model's Extensions ... /// public static class XModelExtensions { /// /// Validate a Model ... /// /// /// public static bool IsValid(this XContent source) { // var result = !source.IsNullOrDefault() && !source.Title.IsNullOrEmpty() && !source.OwnerId.IsNullOrEmpty(); // return result; } /// /// Validate a Model ... /// /// /// public static bool IsValid(this XContentDto source) { // var result = !source.IsNullOrDefault() && !source.Title.IsNullOrEmpty() && !source.OwnerId.IsNullOrEmpty(); // return result; } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Helpers\XContentServiceHelper.cs using System; using GraphQL.Types; using xDataService.Db; using xDataService.Models; using xDataService.Providers; using xContentService.Models.Entities; using xContentService.Providers.GraphQL; using xContentService.Providers.Entities; using xContentService.Interfaces.Entities; 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 > GetXContentEFRepositoryDescriptor() where TContext : XDbContext { // var result = new XEFRepositoryDescriptor< XContent, Guid, IXContentKeyGenerator, XContentKeyGenerator, IXContentRepositoryEvents, XContentRepositoryEvents, XContentGraphType, GuidGraphType, XContentGraphQuery, IXContentGraphQLTypeHelper, XContentGraphQLTypeHelper, XContentGraphSchema, IXContentRepository, XContentEFRepository, TContext >(); // return result; } public static XEFRepositoryDescriptor< XContent, Guid, IXContentKeyGenerator, XContentKeyGenerator, IXContentRepositoryEvents, XContentRepositoryEvents, XContentGraphType, GuidGraphType, XContentGraphQuery, IXContentGraphQLTypeHelper, XContentGraphQLTypeHelper, XContentGraphSchema, IXContentRepository, XContentEFRepository, TContext, IXContentSeeder, TSeederImplementation > GetXContentEFRepositoryDescriptor() where TContext : XDbContext where TSeederImplementation : XBaseDbSeeder { // var result = new XEFRepositoryDescriptor< XContent, Guid, IXContentKeyGenerator, XContentKeyGenerator, IXContentRepositoryEvents, XContentRepositoryEvents, XContentGraphType, GuidGraphType, XContentGraphQuery, IXContentGraphQLTypeHelper, XContentGraphQLTypeHelper, XContentGraphSchema, IXContentRepository, XContentEFRepository, 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() where TSeederImplementation : XBaseDbSeeder { // 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() where TSeederImplementation : XBaseDbSeeder { // var result = new XInMemoryRepositoryDescriptor< XContent, Guid, IXContentKeyGenerator, XContentKeyGenerator, IXContentRepositoryEvents, XContentRepositoryEvents, XContentGraphType, GuidGraphType, XContentGraphQuery, IXContentGraphQLTypeHelper, XContentGraphQLTypeHelper, XContentGraphSchema, IXContentRepository, XContentInMemoryRepository, IXContentSeeder, TSeederImplementation >(); // return result; } #endregion #endregion } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\IXContentDescriptionResourceProvider.cs using xStringService.Interfaces; namespace xContentService.Interfaces { public interface IXContentDescriptionResourceProvider : IXItemResourceProvider { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\IXContentProvider.cs using System; using System.Threading; using xTagService.Interfaces; using System.Threading.Tasks; using xIdentityModels.Models; using xContentService.Models.Dtos; using xContentService.Providers.Dtos; using xContentService.Models.Entities; namespace xContentService.Interfaces { public interface IXContentProvider : IXBaseProvidedHasTag { /// /// Add an item values ... /// /// /// /// /// /// /// public Task Add( XContentDto item, XUserClaimsInfoDto userInfo = null, string connectionId = null, string language = null, CancellationToken cancellationToken = default ); /// /// Create Content Used Locales for Creating Posts ... /// /// /// /// /// /// // public Task Create( // XContentDto item, // XUserClaimsInfoDto userInfo = null, // string connectionId = null, // CancellationToken cancellationToken = default // ); } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\IXContentTagProvided.cs using System; using xTagService.Interfaces; using xContentService.Models.Dtos; using xContentService.Providers.Dtos; using xContentService.Models.Entities; namespace xContentService.Interfaces { public interface IXContentTagProvided : IXTagProvided { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\IXContentTagProvider.cs using System; using xTagService.Interfaces; namespace xContentService.Interfaces { public interface IXContentTagProvider : IXBaseTagProvider { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\IXContentTitleResourceProvider.cs using xStringService.Interfaces; namespace xContentService.Interfaces { public interface IXContentTitleResourceProvider : IXItemResourceProvider { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Controllers\IXContentProviderController.cs using System; using System.Threading; using xTagService.Interfaces; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using xContentService.Models.Dtos; using xContentService.Providers.Dtos; using xContentService.Models.Entities; namespace xContentService.Interfaces.Controllers { public interface IXContentProviderController : IXBaseProvidedHasTagController { /// /// Add an item ... /// /// /// /// /// [HttpPost("Add")] Task> Add( [FromBody] XContentDto item, [FromQuery] string language = null, CancellationToken cancellationToken = default ); } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Dtos\IXContentDtoHub.cs using System; using xPushService.Interfaces; using xContentService.Models.Dtos; using xContentService.Models.Entities; namespace xContentService.Interfaces.Dtos { public interface IXContentDtoHub : IXBaseDtoHub { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Dtos\IXContentRepositoryService.cs using System; using xDataService.Interfaces; using xContentService.Models.Dtos; using xContentService.Models.Entities; namespace xContentService.Interfaces.Dtos { public interface IXContentRepositoryService : IXBaseRepositoryService { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Dtos\IXContentServiceProvider.cs using System; using xPushService.Interfaces; using xContentService.Models.Dtos; using xContentService.Providers.Dtos; using xContentService.Models.Entities; namespace xContentService.Interfaces.Dtos { public interface IXContentServiceProvider : IXBaseDtoProvider { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Enrichers\IXContentEnricher.cs using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using xContentService.Models.Dtos; using xContentService.Models.Entities; namespace xContentService.Interfaces.Enrichers { public interface IXContentEnricher { // #region Enrichers ... /// /// Enrich Specified Item ... /// /// /// /// Task Enrich( XContent source, CancellationToken cancellationToken = default ); /// /// Enrich Specified Item ... /// /// /// /// Task Enrich( XContentDto source, CancellationToken cancellationToken = default ); /// /// Enrich Specified Items ... /// /// /// /// Task> EnrichRange( IEnumerable sources, CancellationToken cancellationToken = default ); /// /// Enrich Specified Items ... /// /// /// /// Task> EnrichRange( IEnumerable sources, CancellationToken cancellationToken = default ); #endregion } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentEntityHub.cs using System; using xPushService.Interfaces; using xContentService.Models.Entities; namespace xContentService.Interfaces.Entities { public interface IXContentEntityHub : IXBaseEntityHub { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentGraphQLTypeHelper.cs using System; using xDataService.Interfaces; using xContentService.Models.Entities; namespace xContentService.Interfaces.Entities { public interface IXContentGraphQLTypeHelper : IXBaseGraphQLTypeHelper { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentKeyGenerator.cs using System; using xDataService.Interfaces; using xContentService.Models.Entities; namespace xContentService.Interfaces.Entities { public interface IXContentKeyGenerator : IXKeyGenerator { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentRepository.cs using System; using xDataService.Interfaces; using xContentService.Models.Entities; namespace xContentService.Interfaces.Entities { public interface IXContentRepository : IXBaseRepository { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentRepositoryEvents.cs using xDataService.Interfaces; using xContentService.Models.Entities; namespace xContentService.Interfaces.Entities { public interface IXContentRepositoryEvents : IXBaseRepositoryEvents { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentRepositoryProvider.cs using System; using xPushService.Interfaces; using xContentService.Models.Entities; using xContentService.Providers.Entities; namespace xContentService.Interfaces.Entities { public interface IXContentRepositoryProvider : IXBaseEntityProvider { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Interfaces\Entities\IXContentSeeder.cs using System; using xDataService.Interfaces; using xContentService.Models.Entities; namespace xContentService.Interfaces.Entities { public interface IXContentSeeder : IXBaseDbSeeder { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Models\Dtos\XContentDto.cs using System; using xModels.Base; using xModels.Dtos; namespace xContentService.Models.Dtos { /// /// Content Describe DTO ... /// 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 string[] Tags { get; set; } public DateTime CreatedOn { get; set; } public DateTime UpdatedAt { get; set; } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Models\Entities\XContent.cs using System; using xModels.Base; using System.ComponentModel.DataAnnotations; namespace xContentService.Models.Entities { /// /// Content Describe ... /// public class XContent : XBaseGuidIDEntity { /// /// User Identifier ... /// /// [Required] [StringLength(255)] public string OwnerId { get; set; } /// /// Title of Content ... /// [Required] [StringLength(255)] public string Title { get; set; } /// /// Description of Content ... /// [StringLength(255)] public string Description { get; set; } /// /// Created Time ... /// public DateTime CreatedOn { get; set; } /// /// Updated Time ... /// public DateTime UpdatedAt { get; set; } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\XContentDescriptionResourceProvider.cs using xStringService.Providers; using xContentService.Constants; using xContentService.Interfaces; using xStringService.Interfaces.Dtos; namespace xContentService.Providers { public class XContentDescriptionResourceProvider : XBaseItemResourceProvider, IXContentDescriptionResourceProvider { public XContentDescriptionResourceProvider( IXStringServiceProvider stringProvider ) : base( stringProvider: stringProvider, item: XContentServiceConstants.XContentDescriptionIdentifier ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\XContentEntityRegisterar.cs using System; using xDataService.Providers; using xDataService.Interfaces; using Microsoft.EntityFrameworkCore; using xContentService.Models.Entities; using xContentService.Configuration.Entities; namespace xContentService.Providers { public class XContentEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar { public XContentEntityRegisterar() : base(nameof(XContentEntityRegisterar)) { // // Add Entity ... AddEntity(); } /// /// Configure Entities ... /// /// public override void ConfigureEntities(ModelBuilder modelBuilder) { // // Configure Entity Using Provided ... modelBuilder .ApplyConfigurationsFromAssembly(typeof(XContentEntityConfiguration).Assembly); // base.ConfigureEntities(modelBuilder); } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\XContentProvider.cs using System; using System.Linq; using xModels.Dtos; using System.Threading; using xCommons.Extensions; using xTagService.Providers; using xExceptions.Constants; using xIdentityModels.Models; using System.Threading.Tasks; using xPushService.Constants; using System.Linq.Expressions; using xCommons.Configurations; using xContentService.Constants; using xContentService.Interfaces; using System.Collections.Generic; using xContentService.Extensions; using xContentService.Models.Dtos; using xContentService.Providers.Dtos; using xContentService.Models.Entities; using xContentService.Interfaces.Dtos; using Microsoft.EntityFrameworkCore.Query; using xContentService.Interfaces.Enrichers; namespace xContentService.Providers { public class XContentProvider : XBaseProvidedHasTag, IXContentProvider { private readonly IXContentEnricher enricher; private readonly XAppConfiguration configuration; private readonly IXContentTagProvider tagProvider; private readonly IXContentServiceProvider provider; private readonly IXContentTitleResourceProvider titleResourceProvider; private readonly IXContentDescriptionResourceProvider descriptionResourceProvider; public XContentProvider( IXContentEnricher enricher, XAppConfiguration configuration, IXContentTagProvider tagProvider, IXContentServiceProvider provider, IXContentTitleResourceProvider titleResourceProvider, IXContentDescriptionResourceProvider descriptionResourceProvider ) : base( provider: provider, tagProvider: tagProvider, permittedRoles: [XContentServiceConstants.XAdminRole] ) { this.provider = provider; this.enricher = enricher; this.tagProvider = tagProvider; this.configuration = configuration; this.titleResourceProvider = titleResourceProvider; this.descriptionResourceProvider = descriptionResourceProvider; } public override bool IsOwned( XContent item, XUserClaimsInfoDto userInfo ) { // var result = !item.IsNullOrDefault() && !userInfo.IsNullOrDefault() && !item.OwnerId.IsNullOrEmpty() && userInfo.UserId == item.OwnerId; // return result; } public override bool IsOwned( XContentDto item, XUserClaimsInfoDto userInfo ) { // var result = !item.IsNullOrDefault() && !userInfo.IsNullOrDefault() && !item.OwnerId.IsNullOrEmpty() && userInfo.UserId == item.OwnerId; // return result; } // #region Overrides ... /// /// Get Specified Item by ID ... /// /// /// /// /// public override async Task Get( Guid id, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ) { // // Retrieve Item ... var result = await provider.GetAsync( id: id, includeBuilder: null, ignoreSoftDeleteds: true, cancellationToken: cancellationToken ); // // Handle Enrichment ... if (!result.IsNullOrDefault()) { // result = await enricher.Enrich( source: result, cancellationToken: cancellationToken ); } // return result; } /// /// Get All Exists Items ... /// /// /// /// /// public override async Task> GetAll( Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ) { // // Retrieve Items ... var result = await provider.GetAllAsync( ignoreSoftDeleteds: true, orderBuilder: orderBuilder, includeBuilder: includeBuilder, cancellationToken: cancellationToken ); // // Handle Enrichment ... if (result.HasChild()) { // result = await enricher.EnrichRange( sources: result, cancellationToken: cancellationToken ); } // return result; } /// /// find an item by providing a Conditional Expression ... /// /// /// /// /// public override async Task FindOne( Expression> predicate, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ) { // // Detect Item ... var result = await provider.FindOneAsync( predicate: predicate, ignoreSoftDeleteds: true, includeBuilder: includeBuilder, cancellationToken: cancellationToken ); // // Handle Enrichment ... if (!result.IsNullOrDefault()) { // result = await enricher.Enrich( source: result, cancellationToken: cancellationToken ); } // return result; } /// /// find a collection of Items by proving a Conditional Expression ... /// /// /// /// /// /// public override async Task> FindMany( Expression> predicate, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ) { // // Detect Items ... var result = await provider.FindManyAsync( predicate: predicate, ignoreSoftDeleteds: true, orderBuilder: orderBuilder, includeBuilder: includeBuilder, cancellationToken: cancellationToken ); // // Handle Enrichment ... if (result.HasChild()) { // result = await enricher.EnrichRange( sources: result, cancellationToken: cancellationToken ); } // return result; } /// /// retrieve Items based on XQuery Pagination structure ... /// /// /// /// /// /// /// public override async Task> Query( XQuery query, Expression> predicate = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ) { // // Query Items ... var result = await provider.QueryAsync( query: query, predicate: predicate, ignoreSoftDeleteds: true, orderBuilder: orderBuilder, includeBuilder: includeBuilder, cancellationToken: cancellationToken ); // // Handle Enrichment ... if (!result.IsNullOrDefault() && result.Items.HasChild()) { // result.Items = await enricher.EnrichRange( sources: result.Items, cancellationToken: cancellationToken ); } // return result; } /// /// retrieve Owned Items based on XQuery Pagination structure ... /// if supported ... /// /// /// /// /// /// /// /// public override async Task> QueryOwned( XQuery query, XUserClaimsInfoDto userInfo = null, Expression> predicate = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ) { // // Prepare Predicator ... Expression> predicateor = null; if (!predicate.IsNull()) { // var predicateFnc = predicate.Compile(); predicateor = x => predicateFnc(x) && IsOwned(x, userInfo); } else { predicateor = x => IsOwned(x, userInfo); } // // Query Items ... var result = await provider.QueryAsync( query: query, predicate: predicateor, ignoreSoftDeleteds: true, orderBuilder: orderBuilder, includeBuilder: includeBuilder, cancellationToken: cancellationToken ); // // Handle Enrichment ... if (!result.IsNullOrDefault() && result.Items.HasChild()) { // result.Items = await enricher.EnrichRange( sources: result.Items, cancellationToken: cancellationToken ); } // return result; } /// /// Add an item values ... /// /// /// /// /// /// public override async Task Add( XContentDto item, XUserClaimsInfoDto userInfo = null, string connectionId = null, CancellationToken cancellationToken = default ) { // var result = await Add( item: item, language: null, userInfo: userInfo, connectionId: connectionId, cancellationToken: cancellationToken ); // return result; } /// /// Add an item values ... /// /// /// /// /// /// /// public async Task Add( XContentDto item, XUserClaimsInfoDto userInfo = null, string connectionId = null, string language = null, CancellationToken cancellationToken = default ) { // // Validate ... var isValid = !item.IsNullOrDefault(); if (!isValid) { XException.InvalidArgs.Throw(); } // // Normalize ... // // Language ... if (language.IsNullOrEmpty()) { language = configuration.DefaultLanguage; } // // Owner Id ... if (item.OwnerId.IsNullOrEmpty()) { // if (!userInfo.IsNullOrDefault()) { item.OwnerId = userInfo.UserId; } } // // Created On ... item.CreatedOn = DateTime.UtcNow; // // Validate Normalized Items ... isValid = item.IsValid(); if (!isValid) { XException.InvalidData.Throw(); } // // Handle Insert Temp ... var result = await provider.AddAsync( item: item, saveChanges: true, connectionId: null, // Ignor Push Notifications ..., cancellationToken: cancellationToken ); isValid = !result.IsNullOrDefault(); if (!isValid) { XException.ActionFailed.Throw(); } // // Handle Insert Title/Description ... // var titleResource = await titleResourceProvider.AddOrUpdateLocale( connectionId: null, identifier: result.Id, locale: new XLocaleResourceDto { Language = language, Value = result.Title, }, cancellationToken: cancellationToken ); // XResourceDto descriptionResource = null; if (!result.Description.IsNullOrEmpty()) { // descriptionResource = await descriptionResourceProvider.AddOrUpdateLocale( connectionId: null, identifier: result.Id, locale: new XLocaleResourceDto { Language = language, Value = result.Description, }, cancellationToken: cancellationToken ); } // // Fill Item Title and Description ... if (titleResource.IsNullOrDefault()) { result.Title = titleResource.Resource; } if (descriptionResource.IsNullOrDefault()) { result.Description = descriptionResource.Resource; } // // Update Item ... result = await Update( item: result, id: result.Id, userInfo: userInfo, connectionId: null, cancellationToken: cancellationToken ); isValid = !result.IsNullOrDefault(); if (!isValid) { XException.ActionFailed.Throw(); } // // Handle Enrichment ... if (isValid) { // result = await enricher.Enrich( source: result, cancellationToken: cancellationToken ); } // // Handle Push Notifications ... if (isValid && !connectionId.IsNullOrEmpty()) { // await provider.SendPush( connectionId: connectionId, cancellationToken: cancellationToken, payLoad: result.ToJSON(camelCase: true), action: XBaseEntityHubAction.Add.GetStringValue() ); } // return result; } /// /// Update an item values ... /// /// /// /// /// /// /// public override async Task Update( Guid id, XContentDto item, XUserClaimsInfoDto userInfo = null, string connectionId = null, CancellationToken cancellationToken = default ) { // // Check Permission ... var hasPermission = IsOwned(item, userInfo) || HasPermision(userInfo); if (!hasPermission) { XException.NotAllowed.Throw(); } // // Handle Resources ... if (!item.TitleResource.IsNullOrDefault()) { item.TitleResource = await titleResourceProvider.AddOrUpdateResource( identifier: item.Id, connectionId: connectionId, resource: item.TitleResource, cancellationToken: cancellationToken ); } // // Handle Update on ... item.UpdatedAt = DateTime.UtcNow; // var result = await provider.UpdateAsync( id: id, item: item, saveChanges: true, connectionId: null, cancellationToken: cancellationToken ); var isValid = !result.IsNullOrDefault(); // // Handle Enrichment ... if (isValid) { // result = await enricher.Enrich( source: result, cancellationToken: cancellationToken ); } // // Handle Notification ... if (isValid && !connectionId.IsNullOrEmpty()) { // await provider.SendPush( connectionId: connectionId, cancellationToken: cancellationToken, payLoad: result.ToJSON(camelCase: true), action: XBaseEntityHubAction.Update.GetStringValue() ); } // return result; } /// /// remove an Item ... /// /// /// /// /// /// public override async Task Remove( Guid id, XUserClaimsInfoDto userInfo = null, string connectionId = null, CancellationToken cancellationToken = default ) { // // Check Permission ... var item = await Get( id: id, cancellationToken: cancellationToken ); var hasPermission = IsOwned(item, userInfo) || HasPermision(userInfo); if (!hasPermission) { XException.NotAllowed.Throw(); } // // Handle Item Remove ... var result = await provider.RemoveAsync( id: id, saveChanges: true, softDelete: false, connectionId: null, cancellationToken: cancellationToken ); if (result.IsNullOrDefault()) { XException.ActionFailed.Throw(); } // // Remove Titles/Descriptions ... // // Titles ... await titleResourceProvider.RemoveLocales( connectionId: null, identifier: result.Id, cancellationToken: cancellationToken ); // // Descriptions ... await descriptionResourceProvider.RemoveLocales( connectionId: null, identifier: result.Id, cancellationToken: cancellationToken ); // // Handle Notifications ... if (!connectionId.IsNullOrEmpty()) { // await provider.SendPush( connectionId: connectionId, cancellationToken: cancellationToken, payLoad: result.ToJSON(camelCase: true), action: XBaseEntityHubAction.Delete.GetStringValue() ); } // return result; } #endregion } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\XContentTagProvided.cs using System; using xCommons.Extensions; using xTagService.Providers; using xIdentityModels.Models; using xContentService.Constants; using xContentService.Interfaces; using xContentService.Models.Dtos; using xContentService.Providers.Dtos; using xContentService.Interfaces.Dtos; using xContentService.Models.Entities; namespace xContentService.Providers { public class XContentTagProvided : XBaseTagProvided, IXContentTagProvided { public XContentTagProvided( IXContentTagProvider tagProvider, IXContentServiceProvider provider ) : base( provider: provider, tagProvider: tagProvider, permittedRoles: [XContentServiceConstants.XAdminRole] ) { } public override bool IsOwned( XContent item, XUserClaimsInfoDto userInfo ) { // var result = !item.IsNullOrDefault() && !userInfo.IsNullOrDefault() && item.OwnerId == userInfo.UserId; // return result; } public override bool IsOwned( XContentDto item, XUserClaimsInfoDto userInfo ) { // var result = !item.IsNullOrDefault() && !userInfo.IsNullOrDefault() && item.OwnerId == userInfo.UserId; // return result; } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\XContentTagProvider.cs using System; using xTagService.Providers; using xContentService.Constants; using xContentService.Interfaces; using xTagService.Interfaces.Dtos; namespace xContentService.Providers { public class XContentTagProvider : XBaseTagProvider, IXContentTagProvider { public XContentTagProvider( IXTagServiceProvider tagProvider ) : base( tagProvider: tagProvider, providedFor: XContentServiceConstants.XContentTagProvided ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\XContentTitleResourceProvider.cs using xStringService.Providers; using xContentService.Constants; using xContentService.Interfaces; using xStringService.Interfaces.Dtos; namespace xContentService.Providers { public class XContentTitleResourceProvider : XBaseItemResourceProvider, IXContentTitleResourceProvider { public XContentTitleResourceProvider( IXStringServiceProvider stringProvider ) : base( stringProvider: stringProvider, item: XContentServiceConstants.XContentTitleIdentifier ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Dtos\XContentDtoHub.cs using System; using xPushService.Base; using xContentService.Models.Dtos; using Microsoft.Extensions.Logging; using xContentService.Interfaces.Dtos; using xContentService.Models.Entities; namespace xContentService.Providers.Dtos { public class XContentDtoHub : XBaseDtoHub, IXContentDtoHub { public XContentDtoHub( ILogger logger ) : base(logger) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Dtos\XContentRepositoryService.cs using System; using AutoMapper; using xDataService.Providers; using System.Collections.Generic; using xContentService.Models.Dtos; using xContentService.Interfaces.Dtos; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Dtos { public class XContentRepositoryService : XBaseRepositoryService, IXContentRepositoryService { public XContentRepositoryService( IXContentRepository repository, IEnumerable mapperProfiles = null ) : base( repository, mapperProfiles ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Dtos\XContentServiceProvider.cs using System; using xPushService.Base; using xDataService.Configuration; using xContentService.Models.Dtos; using xIdentityService.Interfaces; using Microsoft.AspNetCore.SignalR; using xContentService.Interfaces.Dtos; using xContentService.Models.Entities; namespace xContentService.Providers.Dtos { public class XContentServiceProvider : XBaseDtoProvider, IXContentServiceProvider { public XContentServiceProvider( IHubContext hub, XDataServiceConfiguration dataConfiguration, IXContentRepositoryService service, IXIdentityProvider identityProvider = null ) : base( hub, dataConfiguration, service, identityProvider ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Enrichers\XContentEnricher.cs using System.Linq; using xModels.Dtos; using System.Threading; using xCommons.Extensions; using System.Threading.Tasks; using System.Collections.Generic; using xContentService.Interfaces; using xContentService.Models.Dtos; using xIdentityService.Interfaces; using xIdentityService.Extensions; using xContentService.Models.Entities; using xContentService.Interfaces.Enrichers; namespace xContentService.Providers.Enrichers { public class XContentEnricher : IXContentEnricher { private readonly IXContentTagProvided tagProvider; private readonly IXIdentityProvider identityProvider; private readonly IXContentTitleResourceProvider titleResourceProvider; private readonly IXContentDescriptionResourceProvider descriptionResourceProvider; public XContentEnricher( IXContentTagProvided tagProvider, IXIdentityProvider identityProvider, IXContentTitleResourceProvider titleResourceProvider, IXContentDescriptionResourceProvider descriptionResourceProvider ) { this.tagProvider = tagProvider; this.identityProvider = identityProvider; this.titleResourceProvider = titleResourceProvider; this.descriptionResourceProvider = descriptionResourceProvider; } // #region Enrichers ... /// /// Enrich Specified Item ... /// /// /// /// public async Task Enrich( XContent source, CancellationToken cancellationToken = default ) { // // Mapping Default ... var result = source.MapConvert(); result = await Enrich( source: result, cancellationToken: cancellationToken ); // return result; } /// /// Enrich Specified Item ... /// /// /// /// public async Task Enrich( XContentDto source, CancellationToken cancellationToken = default ) { // // Handdle Owner ... XPersonDto owner = null; if (!source.OwnerId.IsNullOrEmpty()) { // // Try to Retrieve User Info ... var device = identityProvider.GetDevice(); var userInfo = await identityProvider.GetUserInfo( device: device, userSelectByParam: source.OwnerId ); owner = userInfo.ToXPersonDto(); } // // Hanlde Content Title ... string contentTitle = string.Empty; XResourceDto titleResource = await titleResourceProvider.GetResource( identifier: source.Id, cancellationToken: cancellationToken ); if (!titleResource.IsNullOrDefault()) { contentTitle = titleResource.Resource; } // // Hanlde Content Description ... string contentDescription = string.Empty; XResourceDto descriptionResource = await descriptionResourceProvider.GetResource( identifier: source.Id, cancellationToken: cancellationToken ); if (!descriptionResource.IsNullOrDefault()) { contentDescription = descriptionResource.Resource; } // var tags = await tagProvider.GetTags( id: source.Id, cancellationToken: cancellationToken ); // // Attach Extracted Items ... var result = source.MapConvert(); result.Owner = owner; result.Tags = [..tags]; result.Title = contentTitle; result.TitleResource = titleResource; result.Description = contentDescription; result.DescriptionResource = descriptionResource; // return result; } /// /// Enrich Specified Items ... /// /// /// /// public async Task> EnrichRange( IEnumerable sources, CancellationToken cancellationToken = default ) { // var tasks = sources .Select(x => Enrich(x, cancellationToken)); // var result = await Task.WhenAll(tasks); return result; } /// /// Enrich Specified Items ... /// /// /// /// public async Task> EnrichRange( IEnumerable sources, CancellationToken cancellationToken = default ) { // var tasks = sources .Select(x => Enrich(x, cancellationToken)); // var result = await Task.WhenAll(tasks); return result; } #endregion } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentEFRepository.cs using System; using xDataService.Db; using xDataService.Providers; using xDataService.Interfaces; using xDataService.Configuration; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Entities { public class XContentEFRepository : XBaseEFRepository, IXContentRepository where TContext : XDbContext { public XContentEFRepository( IXUnitOfWorks unitOfWorks, XDataServiceConfiguration configuration, IXContentKeyGenerator keyGenerator = null, IXContentRepositoryEvents baseRepositoryEvents = null ) : base( unitOfWorks, configuration, keyGenerator, baseRepositoryEvents ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentEntityHub.cs using System; using xPushService.Base; using Microsoft.Extensions.Logging; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Entities { public class XContentEntityHub : XBaseEntityHub, IXContentEntityHub { public XContentEntityHub( ILogger logger ) : base(logger) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentInMemoryRepository.cs using System; using xDataService.Providers; using xDataService.Configuration; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Entities { public class XContentInMemoryRepository : XBaseInMemoryRepository, IXContentRepository { public XContentInMemoryRepository( XDataServiceConfiguration configuration, IXContentKeyGenerator keyGenerator = null, IXContentRepositoryEvents baseRepositoryEvents = null ) : base( configuration, keyGenerator, baseRepositoryEvents ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentKeyGenerator.cs using xDataService.Providers; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Entities { public class XContentKeyGenerator : XGuidKeyGenerator, IXContentKeyGenerator { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentMongoRepository.cs using System; using xDataService.Providers; using xDataService.Configuration; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Entities { public class XContentMongoRepository : XBaseMongoRepository, IXContentRepository { public XContentMongoRepository( XDataBaseConfiguration dbConfiguration, XDataServiceConfiguration configuration, string collectionName = null, IXContentKeyGenerator keyGenerator = null, IXContentRepositoryEvents baseRepositoryEvents = null ) : base( dbConfiguration, configuration, collectionName, keyGenerator, baseRepositoryEvents ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentRepositoryEvents.cs using xDataService.Providers; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Entities { public class XContentRepositoryEvents : XBaseRepositoryEvents, IXContentRepositoryEvents { } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentRepositoryProvider.cs using System; using xPushService.Base; using xDataService.Configuration; using xIdentityService.Interfaces; using Microsoft.AspNetCore.SignalR; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Entities { public class XContentRepositoryProvider : XBaseEntityProvider, IXContentRepositoryProvider { public XContentRepositoryProvider( IHubContext hub, IXContentRepository repository, XDataServiceConfiguration dataConfiguration, IXIdentityProvider identityProvider = null ) : base( hub, repository, dataConfiguration, identityProvider ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\Entities\XContentSeederBase.cs using System; using xDataService.Providers; using xDataService.Configuration; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.Entities { public abstract class XContentSeederBase : XBaseDbSeeder, IXContentSeeder { protected XContentSeederBase( string entity, string database, IXContentRepository repository, XDataServiceConfiguration dataServiceConfiguration ) : base( entity, database, repository, dataServiceConfiguration ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\GraphQL\XContentGraphQLTypeHelper.cs using System; using xDataService.GraphQL; using xContentService.Constants; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.GraphQL { public class XContentGraphQLTypeHelper : XBaseGraphQLTypeHelper, IXContentGraphQLTypeHelper { public override string GetInQueryCollectionName() { return XContentServiceConstants.XContentCollectionName; } public override string GetInQuerySingleName() { return XContentServiceConstants.XContentSingleName; } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\GraphQL\XContentGraphQuery.cs using System; using GraphQL.Types; using xDataService.GraphQL; using xDataService.Configuration; using xContentService.Models.Entities; using xContentService.Interfaces.Entities; namespace xContentService.Providers.GraphQL { public class XContentGraphQuery : XBaseGraphQLQuery { public XContentGraphQuery( XDataServiceConfiguration configuration, IXContentRepository repository, IXContentGraphQLTypeHelper helper ) : base( configuration, repository, helper ) { } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\GraphQL\XContentGraphSchema.cs 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)); } } } ### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xContentService\Providers\GraphQL\XContentGraphType.cs using System; using xDataService.GraphQL; using xContentService.Models.Entities; namespace xContentService.Providers.GraphQL { public class XContentGraphType : XBaseGraphObjectType { public XContentGraphType() : base() { Field(x => x.Title); Field(x => x.OwnerId); Field(x => x.CreatedOn); Field(x => x.UpdatedAt); Field(x => x.Description); } } }