diff --git a/DI/XDIHelperExtension.cs b/DI/XDIHelperExtension.cs
index 9888906..22b7074 100644
--- a/DI/XDIHelperExtension.cs
+++ b/DI/XDIHelperExtension.cs
@@ -1,16 +1,11 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using xAiService.DI;
using xCommons.Extensions;
-using xFileService.DI;
using xMessageService.DI;
using xServices.Configurations;
using xServices.Constants;
-using xServices.TermsConditions.DI;
using xStorageService.DI;
-using xStringService.DI;
-using xTagService.DI;
namespace xServices.DI
{
@@ -154,36 +149,13 @@ namespace xServices.DI
config = new XServicesConfiguration();
}
- //
- // Tag Service ...
- services.AddXTagService(lifeTime: lifeTime);
-
//
// Storage Service ...
services.AddXStorageService(configuration);
- //
- // File Service ...
- services.AddXFileService(lifeTime: lifeTime);
-
//
// Message Service ...
services.AddXMessageService(config: configuration);
-
- //
- // String Servicce ...
- services.AddXStringService(lifeTime: lifeTime);
-
- //
- // Terms and Conditions Service ...
- services.AddXTermsConditionsService(lifeTime: lifeTime);
-
- //
- // Ai Service ...
- services.AddXAIService(
- lifeTime: lifeTime,
- configuration: configuration
- );
}
#endregion
}
diff --git a/TermsConditions/Controllers/XTermsConditionsControllerActions.cs b/TermsConditions/Controllers/XTermsConditionsControllerActions.cs
deleted file mode 100644
index c5d0327..0000000
--- a/TermsConditions/Controllers/XTermsConditionsControllerActions.cs
+++ /dev/null
@@ -1,270 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Logging;
-using xCommons.Configurations;
-using xCommons.Extensions;
-using xCommons.Providers;
-using xIdentityService.Controllers;
-using xIdentityService.Interfaces;
-using xServices.TermsConditions.Interfaces;
-
-namespace xServices.TermsConditions.Controllers
-{
- ///
- /// a Controller base Class which implement based Actions to Provides Terms and Conditions Provider Access ...
- ///
- public abstract class XTermsConditionsControllerActions : XIBaseProviderController, IXTermsConditionsControllerActions
- {
- //
- #region Props ...
- public IXTermsComditionsProvider TermsProvider { get; }
- #endregion
-
- //
- #region Constructor ...
- public XTermsConditionsControllerActions(
- ILogger logger,
- XAppConfiguration appConfiguration,
- IXIdentityProvider identityProvider,
- XValidationProvider validationProvider,
- IXTermsComditionsProvider termsProvider
- ) : base(
- logger,
- appConfiguration,
- identityProvider,
- validationProvider
- )
- {
- //
- TermsProvider = termsProvider;
- }
- #endregion
-
- //
- #region Actions ...
- ///
- /// Retrieved all Exists Languages Terms and Conditions ...
- ///
- ///
- [HttpGet("Terms/Languages")]
- public async Task>> TermsLanguages()
- {
- //
- // Do ...
- try
- {
- //
- // Retrieve User Info ...
- var userInfo = await GetUserInfo();
- var connectionId = GetConnectionId();
-
- //
- var result = await TermsProvider.TermsLanguages();
-
- //
- return Ok(result
- .ToDynamicObject());
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// Check Has Terms and Conditions based on Specified Language ...
- ///
- /// if null, used Default Language ...
- ///
- [HttpGet("Terms/{language}/Has")]
- public async Task> HasTerms(
- [FromRoute] string language = null
- )
- {
- //
- // Do ...
- try
- {
- //
- // Retrieve User Info ...
- var userInfo = await GetUserInfo();
- var connectionId = GetConnectionId();
-
- //
- var result = await TermsProvider.HasTerms(
- language: language
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// Retrieve Terms and Conditions for Specified Language ...
- ///
- /// if null, used Default Language ...
- ///
- [HttpGet("Terms/{language}")]
- public async Task> GetTerms(
- [FromRoute] string language = null
- )
- {
- //
- // Do ...
- try
- {
- //
- // Retrieve User Info ...
- var userInfo = await GetUserInfo();
- var connectionId = GetConnectionId();
-
- //
- var result = await TermsProvider.GetTerms(
- language: language
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// Add Terms and Conditions for Specified Language ...
- ///
- ///
- ///
- ///
- [HttpPost("Terms/{language}")]
- public async Task> AddTerms(
- [FromRoute] string language,
- [FromQuery] string terms
- )
- {
- //
- // Do ...
- try
- {
- //
- // Retrieve User Info ...
- var userInfo = await GetUserInfo();
- var connectionId = GetConnectionId();
-
- //
- var result = await TermsProvider.AddTerms(
- language: language,
- terms: terms,
- userInfo: userInfo,
- connectionId: connectionId
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// Remove Terms and Conditions of Specified Language ...
- ///
- ///
- ///
- [HttpDelete("Terms/{language}")]
- public async Task> RemoveTerms(
- [FromRoute] string language
- )
- {
- //
- // Do ...
- try
- {
- //
- // Retrieve User Info ...
- var userInfo = await GetUserInfo();
- var connectionId = GetConnectionId();
-
- //
- var result = await TermsProvider.RemoveTerms(
- language: language,
- userInfo: userInfo,
- connectionId: connectionId
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
-
- ///
- /// Update Terms and Conditions of Specified Language ...
- ///
- ///
- ///
- ///
- [HttpPut("Terms/{language}")]
- public async Task> UpdateTerms(
- [FromRoute] string language,
- [FromQuery] string terms
- )
- {
- //
- // Do ...
- try
- {
- //
- // Retrieve User Info ...
- var userInfo = await GetUserInfo();
- var connectionId = GetConnectionId();
-
- //
- var result = await TermsProvider.UpdateTerms(
- language: language,
- terms: terms,
- userInfo: userInfo,
- connectionId: connectionId
- );
-
- //
- return Ok(result);
- }
- catch (Exception ex)
- {
- //
- var result = GetExceptionActionResult(ex);
- return result;
- }
- }
- #endregion
-
- //
- #region NonActions ...
- #endregion
- }
-}
\ No newline at end of file
diff --git a/TermsConditions/DI/TermsConditionsExtensions.cs b/TermsConditions/DI/TermsConditionsExtensions.cs
deleted file mode 100644
index 3a463bc..0000000
--- a/TermsConditions/DI/TermsConditionsExtensions.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System;
-using Microsoft.Extensions.DependencyInjection;
-using xCommons.Configurations;
-using xCommons.Extensions;
-using xExceptions.Constants;
-using xServices.TermsConditions.Interfaces;
-using xServices.TermsConditions.Provides;
-using xStringService.Interfaces.Entities;
-
-namespace xServices.TermsConditions.DI
-{
- public static class TermsConditionsExtensions
- {
- ///
- /// Register TermsConditions Provider ...
- ///
- ///
- ///
- public static void AddXTermsConditionsService(
- this IServiceCollection services,
- ServiceLifetime lifeTime = ServiceLifetime.Transient
- )
- {
- //
- AddTermsConditionsService(
- services: services,
- lifeTime: lifeTime
- );
- }
-
- //
- #region Private ...
- ///
- /// a LogTag for Service ...
- ///
- private static string XLogTag = "XTermsConditionsService";
-
- ///
- /// print a log in Console ...
- ///
- ///
- private static void Log(string message)
- {
- Console.WriteLine($"{XLogTag} => {message}");
- }
-
- ///
- /// Add Terms and Conditions Provider Service ...
- ///
- ///
- ///
- private static void AddTermsConditionsService(
- IServiceCollection services,
- ServiceLifetime lifeTime = ServiceLifetime.Transient
- )
- {
- //
- var exception = XException.InvalidArgs.ToException(); ;
-
- //
- // Services ...
- var isServicesExists = !services.IsNull();
- if (!isServicesExists)
- {
- //
- Log("AddTermsConditions failed, services not provided ...");
- throw exception;
- }
-
- //
- // Lifetime ...
- var isLifetimeExists = !lifeTime.IsNull();
- if (!isLifetimeExists)
- {
- //
- Log("AddTermsConditions failed, lifetime not provided ...");
- throw exception;
- }
-
- //
- // Check Dependencies Exists ...
- var isDependenciesPassed = !services
- .GetRegisteredService()
- .IsNull() &&
- !services.GetRegisteredService()
- .IsNull();
- if (!isDependenciesPassed)
- {
- //
- Log("AddTermsConditions failed due Dependencies Issues, IXStringRepository or XAppConfiguration not provided ...");
- throw exception;
- }
-
- //
- // Register Resource Providers ...
- services.Add(new ServiceDescriptor(typeof(IXTermsComditionsProvider), typeof(XTermsComditionsProvider), lifeTime));
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/TermsConditions/Interfaces/IXTermsComditionsProvider.cs b/TermsConditions/Interfaces/IXTermsComditionsProvider.cs
deleted file mode 100644
index f2d6735..0000000
--- a/TermsConditions/Interfaces/IXTermsComditionsProvider.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using xIdentityModels.Models;
-
-namespace xServices.TermsConditions.Interfaces
-{
- public interface IXTermsComditionsProvider
- {
- //
- #region Actions ...
- ///
- /// Retrieved all Exists Languages Terms and Conditions ...
- ///
- ///
- Task> TermsLanguages();
-
- ///
- /// Check Has Terms and Conditions based on Specified Language ...
- ///
- /// if null, used Default Language ...
- ///
- Task HasTerms(string language = null);
-
- ///
- /// Retrieve Terms and Conditions for Specified Language ...
- ///
- /// if null, used Default Language ...
- ///
- Task GetTerms(string language = null);
-
- ///
- /// Add Terms and Conditions for Specified Language ...
- ///
- ///
- ///
- ///
- ///
- ///
- Task AddTerms(
- string language,
- string terms,
- XUserClaimsInfoDto userInfo = null,
- string connectionId = null
- );
-
- ///
- /// Remove Terms and Conditions of Specified Language ...
- ///
- ///
- ///
- ///
- ///
- Task RemoveTerms(
- string language,
- XUserClaimsInfoDto userInfo = null,
- string connectionId = null
- );
-
- ///
- /// Update Terms and Conditions of Specified Language ...
- ///
- ///
- ///
- ///
- ///
- ///
- Task UpdateTerms(
- string language,
- string terms,
- XUserClaimsInfoDto userInfo = null,
- string connectionId = null
- );
- #endregion
- }
-}
\ No newline at end of file
diff --git a/TermsConditions/Interfaces/IXTermsConditionsControllerActions.cs b/TermsConditions/Interfaces/IXTermsConditionsControllerActions.cs
deleted file mode 100644
index d2ec9c7..0000000
--- a/TermsConditions/Interfaces/IXTermsConditionsControllerActions.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-
-namespace xServices.TermsConditions.Interfaces
-{
- public interface IXTermsConditionsControllerActions
- {
- ///
- /// Terms and Conditions Provider ...
- ///
- IXTermsComditionsProvider TermsProvider { get; }
-
- ///
- /// Retrieved all Exists Languages Terms and Conditions ...
- ///
- ///
- Task>> TermsLanguages();
-
- ///
- /// Check Has Terms and Conditions based on Specified Language ...
- ///
- /// if null, used Default Language ...
- ///
- Task> HasTerms(
- [FromRoute] string language = null
- );
-
- ///
- /// Retrieve Terms and Conditions for Specified Language ...
- ///
- /// if null, used Default Language ...
- ///
- Task> GetTerms(
- [FromRoute] string language = null
- );
-
- ///
- /// Add Terms and Conditions for Specified Language ...
- ///
- ///
- ///
- ///
- Task> AddTerms(
- [FromRoute] string language,
- [FromQuery] string terms
- );
-
- ///
- /// Remove Terms and Conditions of Specified Language ...
- ///
- ///
- ///
- Task> RemoveTerms(
- [FromRoute] string language
- );
-
- ///
- /// Update Terms and Conditions of Specified Language ...
- ///
- ///
- ///
- ///
- Task> UpdateTerms(
- [FromRoute] string language,
- [FromQuery] string terms
- );
- }
-}
\ No newline at end of file
diff --git a/TermsConditions/Provides/XTermsComditionsProvider.cs b/TermsConditions/Provides/XTermsComditionsProvider.cs
deleted file mode 100644
index cf6f937..0000000
--- a/TermsConditions/Provides/XTermsComditionsProvider.cs
+++ /dev/null
@@ -1,411 +0,0 @@
-using xStringService.Interfaces.Entities;
-using xServices.TermsConditions.Interfaces;
-using System.Threading.Tasks;
-using xCommons.Extensions;
-using xCommons.Configurations;
-using xStringService.Models.Entities;
-using xExceptions.Constants;
-using xIdentityModels.Models;
-using System.Linq;
-using Microsoft.AspNetCore.SignalR;
-using xServices.TermsConditions.Push;
-using System.Collections.Generic;
-using xPushService.Constants;
-
-namespace xServices.TermsConditions.Provides
-{
- public class XTermsComditionsProvider : IXTermsComditionsProvider
- {
- //
- #region Props ...
- private readonly string termsId;
- private readonly IHubContext hub;
- private readonly XAppConfiguration appConfiguration;
- private readonly IXStringRepository stringRepository;
- #endregion
-
- //
- #region Constructor ...
- public XTermsComditionsProvider(
- XAppConfiguration appConfiguration,
- IXStringRepository stringRepository,
- IHubContext hub = null,
- string termsId = "terms"
- )
- {
- //
- this.termsId = termsId;
- this.stringRepository = stringRepository;
- this.hub = hub;
- this.appConfiguration = appConfiguration;
- }
- #endregion
-
- //
- #region Actions ...
- ///
- /// Retrieved all Exists Languages Terms and Conditions ...
- ///
- ///
- public async Task> TermsLanguages()
- {
- //
- var result = (await stringRepository
- .FindManyAsync(x => x.ResourceTitle == termsId))
- .Select(x => x.Language);
- return result;
- }
-
- ///
- /// Check Has Terms and Conditions based on Specified Language ...
- ///
- /// if null, used Default Language ...
- ///
- public async Task HasTerms(string language = null)
- {
- //
- // Normalize ...
- if (language.IsNullOrEmpty())
- {
- language = appConfiguration.DefaultLanguage;
- }
-
- //
- var result = !(await GetString(language: language))
- .IsNullOrDefault();
-
- //
- return result;
- }
-
- ///
- /// Retrieve Terms and Conditions for Specified Language ...
- ///
- /// if null, used Default Language ...
- ///
- public async Task GetTerms(string language = null)
- {
- //
- var result = string.Empty;
- var entity = await GetString(language: language);
-
- //
- if (!entity.IsNullOrDefault())
- {
- result = entity.TranslatedValue;
- }
-
- //
- return result;
- }
-
- ///
- /// Add Terms and Conditions for Specified Language ...
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task AddTerms(
- string language,
- string terms,
- XUserClaimsInfoDto userInfo = null,
- string connectionId = null
- )
- {
- //
- // Validate ...
- var isValid =
- !language.IsNullOrEmpty() &&
- !terms.IsNullOrEmpty() &&
- !userInfo.IsNullOrDefault() &&
- language != appConfiguration.DefaultLanguage;
- if (!isValid)
- {
- XException.InvalidArgs.Throw();
- }
-
- //
- // Check Exists ...
- isValid = await HasTerms(language: language);
- if (isValid)
- {
- XException.Duplicate.Throw();
- }
-
- //
- // Check Permission ...
- isValid =
- !userInfo.IsNullOrDefault() &&
- userInfo.Roles.Any(r => r.ToNormalString().Contains("admin"));
- if (!isValid)
- {
- XException.NotAllowed.Throw();
- }
-
- //
- // Add Terms ...
- XString entity = null;
- try
- {
- //
- entity = new XString
- {
- Language = language,
- ResourceTitle = termsId,
- TranslatedValue = terms,
- };
- entity = await stringRepository.AddAsync(entity);
- }
- catch { }
-
- //
- var result = string.Empty;
- if (!entity.IsNullOrDefault())
- {
- result = entity.TranslatedValue;
- }
-
- //
- if (!result.IsNullOrEmpty())
- {
- //
- await SendPush(
- action: XBaseEntityHubAction.Add.GetStringValue(),
- payLoad: entity.ToJSON(camelCase: true),
- connectionId: connectionId
- );
- }
-
- //
- return result;
- }
-
- ///
- /// Remove Terms and Conditions of Specified Language ...
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task RemoveTerms(
- string language,
- XUserClaimsInfoDto userInfo = null,
- string connectionId = null
- )
- {
- //
- var isValid =
- !language.IsNullOrEmpty() &&
- !userInfo.IsNullOrDefault() &&
- language != appConfiguration.DefaultLanguage;
- if (!isValid)
- {
- XException.InvalidArgs.Throw();
- }
-
- //
- // Check Exists ...
- XString entity = await GetString(language);
- isValid = !entity.IsNullOrDefault();
- if (!isValid)
- {
- XException.NotFound.Throw();
- }
-
- //
- // Check Permission ...
- isValid =
- !userInfo.IsNullOrDefault() &&
- userInfo.Roles.Any(r => r.ToNormalString().Contains("admin"));
- if (!isValid)
- {
- XException.NotAllowed.Throw();
- }
-
- //
- try
- {
- entity = await stringRepository.RemoveAsync(entity.Id);
- }
- catch
- {
- entity = null;
- }
-
- //
- var result = !entity.IsNullOrDefault();
- if (result)
- {
- //
- await SendPush(
- action: XBaseEntityHubAction.Delete.GetStringValue(),
- payLoad: entity.ToJSON(camelCase: true),
- connectionId: connectionId
- );
- }
-
- //
- return result;
- }
-
- ///
- /// Update Terms and Conditions of Specified Language ...
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task UpdateTerms(
- string language,
- string terms,
- XUserClaimsInfoDto userInfo = null,
- string connectionId = null
- )
- {
- //
- var isValid =
- !terms.IsNullOrEmpty() &&
- !language.IsNullOrEmpty() &&
- !userInfo.IsNullOrDefault();
- if (!isValid)
- {
- XException.InvalidArgs.Throw();
- }
-
- //
- // Check Exists ...
- XString entity = await GetString(language);
- isValid = !entity.IsNullOrDefault();
- if (!isValid)
- {
- XException.NotFound.Throw();
- }
-
- //
- // Check Permission ...
- isValid =
- !userInfo.IsNullOrDefault() &&
- userInfo.Roles.Any(r => r.ToNormalString().Contains("admin"));
- if (!isValid)
- {
- XException.NotAllowed.Throw();
- }
-
- //
- try
- {
- //
- entity.TranslatedValue = terms;
- entity = await stringRepository.UpdateAsync(entity.Id, entity);
- }
- catch
- {
- entity = null;
- }
-
- //
- var result = !entity.IsNullOrDefault();
- if (result)
- {
- //
- await SendPush(
- action: XBaseEntityHubAction.Update.GetStringValue(),
- payLoad: entity.ToJSON(camelCase: true),
- connectionId: connectionId
- );
- }
-
- //
- return result;
- }
- #endregion
-
- //
- #region Hub Actions ...
- ///
- /// Send Custom Push Message ...
- ///
- ///
- ///
- ///
- ///
- public async Task SendPush(
- string action,
- string payLoad,
- string connectionId = null
- )
- {
- //
- var actions = new List
- {
- XBaseEntityHubAction.Add.GetStringValue(),
- XBaseEntityHubAction.Update.GetStringValue(),
- XBaseEntityHubAction.Delete.GetStringValue(),
- };
-
- //
- // Validate ...
- var isValid =
- !hub.IsNull() &&
- !action.IsNullOrEmpty() &&
- actions.Contains(action);
- if (!isValid)
- {
- return;
- }
-
- //
- var clients = hub.Clients.All;
- if (!connectionId.IsNullOrEmpty())
- {
- clients = hub.Clients.AllExcept(connectionId);
- }
- try
- {
- await clients.SendAsync(action, payLoad, connectionId);
- }
- catch { }
- }
- #endregion
-
- //
- #region Private ...
- ///
- /// Retrieve Terms and Conditions XString Entity ...
- ///
- ///
- ///
- private async Task GetString(string language = null)
- {
- //
- // Normalize ...
- if (language.IsNullOrEmpty())
- {
- language = appConfiguration.DefaultLanguage;
- }
-
- //
- // Retrieve ...
- XString result = null;
- try
- {
- //
- result = await stringRepository.FindOneAsync(x =>
- x.Language == language &&
- x.ResourceTitle == this.termsId
- );
- }
- catch
- {
- }
-
- //
- return result;
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/TermsConditions/Push/XTermsHub.cs b/TermsConditions/Push/XTermsHub.cs
deleted file mode 100644
index 41e5ccc..0000000
--- a/TermsConditions/Push/XTermsHub.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.SignalR;
-using Microsoft.Extensions.Logging;
-using xCommons.Extensions;
-using xPushService.Base;
-using xPushService.Constants;
-using xStringService.Models.Entities;
-
-namespace xServices.TermsConditions.Push
-{
- public class XTermsHub : XBaseHub
- {
- public XTermsHub(ILogger logger) : base(logger)
- {
- }
-
- //
- #region Hub Actions ...
- ///
- /// Add Specified Terms and Conditions ...
- ///
- ///
- ///
- public async Task Add(XString entity)
- {
- //
- var connectionId = Context.ConnectionId;
- if (!connectionId.IsNullOrEmpty())
- {
- //
- await Clients
- .AllExcept(connectionId)
- .SendAsync(
- XBaseEntityHubAction.Add.GetStringValue(),
- entity.ToJSON(camelCase: true),
- connectionId
- );
- }
- }
-
- ///
- /// Deleted Specified Terms and Conditions ...
- ///
- ///
- ///
- public async Task Delete(XString entity)
- {
- //
- var connectionId = Context.ConnectionId;
- if (!connectionId.IsNullOrEmpty())
- {
- //
- await Clients
- .AllExcept(connectionId)
- .SendAsync(
- XBaseEntityHubAction.Delete.GetStringValue(),
- entity.ToJSON(camelCase: true),
- connectionId
- );
- }
- }
-
- ///
- /// Notify an Entity Updated ...
- ///
- ///
- ///
- public async Task Update(XString entity)
- {
- //
- var connectionId = Context.ConnectionId;
- if (!connectionId.IsNullOrEmpty())
- {
- //
- await Clients
- .AllExcept(connectionId)
- .SendAsync(
- XBaseEntityHubAction.Update.GetStringValue(),
- entity.ToJSON(camelCase: true),
- connectionId
- );
- }
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/xServices.csproj b/xServices.csproj
index 9dab801..a1047fa 100644
--- a/xServices.csproj
+++ b/xServices.csproj
@@ -29,9 +29,10 @@
-
+
+
\ No newline at end of file