Initial ...
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
bin
|
||||||
|
obj
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace xServices.Base
|
||||||
|
{
|
||||||
|
public interface IXBaseService
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace xServices.Base
|
||||||
|
{
|
||||||
|
public class XBaseService : IXBaseService
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace xServices.Configurations
|
||||||
|
{
|
||||||
|
public partial class XServicesConfiguration
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace xServices.Constants
|
||||||
|
{
|
||||||
|
public struct ConfigurationNodeNames
|
||||||
|
{
|
||||||
|
public const string SERVICES_NODE = "ServicesConfiguration";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using xExceptions.Attributes;
|
||||||
|
|
||||||
|
namespace xServices.Constants
|
||||||
|
{
|
||||||
|
public class xServicesConstancts
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum XQueryServiceEndPoints
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Specified Endpoint for Users Fetching as Query ...
|
||||||
|
/// </summary>
|
||||||
|
[StringValue("Account/Users/Query")]
|
||||||
|
QueryUsers,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Refresh Tokens ...
|
||||||
|
/// </summary>
|
||||||
|
[StringValue("Account/RefreshTokens")]
|
||||||
|
RefreshTokens,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
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
|
||||||
|
{
|
||||||
|
public static class XDIHelperExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrive Services Configurations ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static XServicesConfiguration GetXServicesConfiguration(
|
||||||
|
this IConfiguration source
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var xConfig = source
|
||||||
|
.GetSection(ConfigurationNodeNames.SERVICES_NODE);
|
||||||
|
var result = xConfig.Get<XServicesConfiguration>();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register Service Configuration ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="configuration"></param>
|
||||||
|
public static void AddXServicesConfiguration(
|
||||||
|
this IServiceCollection services,
|
||||||
|
IConfiguration configuration
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var config = configuration
|
||||||
|
.GetXServicesConfiguration();
|
||||||
|
if (config.IsNull())
|
||||||
|
{
|
||||||
|
config = new XServicesConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
services.AddSingleton<XServicesConfiguration>(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register Service Configuration ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="configuration"></param>
|
||||||
|
public static void AddXServicesConfiguration(
|
||||||
|
this IServiceCollection services,
|
||||||
|
XServicesConfiguration configuration
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (configuration.IsNull())
|
||||||
|
{
|
||||||
|
configuration = new XServicesConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
services.AddSingleton<XServicesConfiguration>(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register Services ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="lifeTime"></param>
|
||||||
|
public static void AddXServices(
|
||||||
|
this IServiceCollection services,
|
||||||
|
IConfiguration configuration,
|
||||||
|
ServiceLifetime lifeTime = ServiceLifetime.Transient
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var config = configuration.GetXServicesConfiguration();
|
||||||
|
|
||||||
|
//
|
||||||
|
AddServices(
|
||||||
|
config: config,
|
||||||
|
services: services,
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
configuration: configuration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register Services ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="configuration"></param>
|
||||||
|
/// <param name="lifeTime"></param>
|
||||||
|
public static void AddXServices(
|
||||||
|
this IServiceCollection services,
|
||||||
|
IConfiguration configuration,
|
||||||
|
XServicesConfiguration config,
|
||||||
|
ServiceLifetime lifeTime = ServiceLifetime.Transient
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddServices(
|
||||||
|
config: config,
|
||||||
|
services: services,
|
||||||
|
lifeTime: lifeTime,
|
||||||
|
configuration: configuration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use All Required Middlewares ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="app"></param>
|
||||||
|
public static void UseXServices(this IApplicationBuilder app)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Use Storage Service ...
|
||||||
|
app.UseXStorageService();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Private ...
|
||||||
|
/// <summary>
|
||||||
|
/// Register Required Services ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="config"></param>
|
||||||
|
/// <param name="lifeTime"></param>
|
||||||
|
private static void AddServices(
|
||||||
|
this IServiceCollection services,
|
||||||
|
IConfiguration configuration,
|
||||||
|
XServicesConfiguration config = null,
|
||||||
|
ServiceLifetime lifeTime = ServiceLifetime.Transient
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check config ...
|
||||||
|
if (config.IsNull())
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace xServices.Extensions
|
||||||
|
{
|
||||||
|
public static class xServicesExtensions
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using xModels.Base;
|
||||||
|
|
||||||
|
namespace xServices.Models
|
||||||
|
{
|
||||||
|
public class XGroupedDataEntity<T, TKey, TGroupedKey>
|
||||||
|
where T : XBaseEntity<TKey>
|
||||||
|
{
|
||||||
|
public TGroupedKey GroupedBy { set; get; }
|
||||||
|
public IEnumerable<T> Members { set; get; }
|
||||||
|
public DateTime TimeStamp { set; get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class XGroupedDataDto<T, TGroupedKey>
|
||||||
|
where T : XBaseDto
|
||||||
|
{
|
||||||
|
public TGroupedKey GroupedBy { set; get; }
|
||||||
|
public IEnumerable<T> Members { set; get; }
|
||||||
|
public DateTime TimeStamp { set; get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# xSaherelmAI.xServices
|
||||||
|
|
||||||
|
it is a Part of xSaherElm AI project which integrated and implements all Required Services ...
|
||||||
|
|
||||||
|
## Maintainer
|
||||||
|
|
||||||
|
Hadi Khazaee asl
|
||||||
|
|
||||||
|
[https://www.saherelm.ir](https://www.saherelm.ir)
|
||||||
|
|
||||||
|
[hadi_khazaee_asl@yahoo.com](mailto:hadi_khazaee_asl@yahoo.com)
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// a Controller base Class which implement based Actions to Provides Terms and Conditions Provider Access ...
|
||||||
|
/// </summary>
|
||||||
|
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 ...
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieved all Exists Languages Terms and Conditions ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("Terms/Languages")]
|
||||||
|
public async Task<ActionResult<IEnumerable<string>>> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check Has Terms and Conditions based on Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language">if null, used Default Language ...</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("Terms/{language}/Has")]
|
||||||
|
public async Task<ActionResult<bool>> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve Terms and Conditions for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language">if null, used Default Language ...</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("Terms/{language}")]
|
||||||
|
public async Task<ActionResult<string>> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add Terms and Conditions for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="terms"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("Terms/{language}")]
|
||||||
|
public async Task<ActionResult<string>> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove Terms and Conditions of Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("Terms/{language}")]
|
||||||
|
public async Task<ActionResult<bool>> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update Terms and Conditions of Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="terms"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut("Terms/{language}")]
|
||||||
|
public async Task<ActionResult<bool>> 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Register TermsConditions Provider ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="lifeTime"></param>
|
||||||
|
public static void AddXTermsConditionsService(
|
||||||
|
this IServiceCollection services,
|
||||||
|
ServiceLifetime lifeTime = ServiceLifetime.Transient
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddTermsConditionsService(
|
||||||
|
services: services,
|
||||||
|
lifeTime: lifeTime
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Private ...
|
||||||
|
/// <summary>
|
||||||
|
/// a LogTag for Service ...
|
||||||
|
/// </summary>
|
||||||
|
private static string XLogTag = "XTermsConditionsService";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// print a log in Console ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
private static void Log(string message)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{XLogTag} => {message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add Terms and Conditions Provider Service ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="lifeTime"></param>
|
||||||
|
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<XAppConfiguration>()
|
||||||
|
.IsNull() &&
|
||||||
|
!services.GetRegisteredService<IXStringRepository>()
|
||||||
|
.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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using xIdentityModels.Models;
|
||||||
|
|
||||||
|
namespace xServices.TermsConditions.Interfaces
|
||||||
|
{
|
||||||
|
public interface IXTermsComditionsProvider
|
||||||
|
{
|
||||||
|
//
|
||||||
|
#region Actions ...
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieved all Exists Languages Terms and Conditions ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<string>> TermsLanguages();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check Has Terms and Conditions based on Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language">if null, used Default Language ...</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> HasTerms(string language = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve Terms and Conditions for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language">if null, used Default Language ...</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> GetTerms(string language = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add Terms and Conditions for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="terms"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string> AddTerms(
|
||||||
|
string language,
|
||||||
|
string terms,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove Terms and Conditions of Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> RemoveTerms(
|
||||||
|
string language,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update Terms and Conditions of Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="terms"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> UpdateTerms(
|
||||||
|
string language,
|
||||||
|
string terms,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
|
string connectionId = null
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace xServices.TermsConditions.Interfaces
|
||||||
|
{
|
||||||
|
public interface IXTermsConditionsControllerActions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Terms and Conditions Provider ...
|
||||||
|
/// </summary>
|
||||||
|
IXTermsComditionsProvider TermsProvider { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieved all Exists Languages Terms and Conditions ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ActionResult<IEnumerable<string>>> TermsLanguages();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check Has Terms and Conditions based on Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language">if null, used Default Language ...</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ActionResult<bool>> HasTerms(
|
||||||
|
[FromRoute] string language = null
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve Terms and Conditions for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language">if null, used Default Language ...</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ActionResult<string>> GetTerms(
|
||||||
|
[FromRoute] string language = null
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add Terms and Conditions for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="terms"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ActionResult<string>> AddTerms(
|
||||||
|
[FromRoute] string language,
|
||||||
|
[FromQuery] string terms
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove Terms and Conditions of Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ActionResult<bool>> RemoveTerms(
|
||||||
|
[FromRoute] string language
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update Terms and Conditions of Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="terms"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ActionResult<bool>> UpdateTerms(
|
||||||
|
[FromRoute] string language,
|
||||||
|
[FromQuery] string terms
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,411 @@
|
|||||||
|
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<XTermsHub> hub;
|
||||||
|
private readonly XAppConfiguration appConfiguration;
|
||||||
|
private readonly IXStringRepository stringRepository;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Constructor ...
|
||||||
|
public XTermsComditionsProvider(
|
||||||
|
XAppConfiguration appConfiguration,
|
||||||
|
IXStringRepository stringRepository,
|
||||||
|
IHubContext<XTermsHub> hub = null,
|
||||||
|
string termsId = "terms"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
this.termsId = termsId;
|
||||||
|
this.stringRepository = stringRepository;
|
||||||
|
this.hub = hub;
|
||||||
|
this.appConfiguration = appConfiguration;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Actions ...
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieved all Exists Languages Terms and Conditions ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<string>> TermsLanguages()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = (await stringRepository
|
||||||
|
.FindManyAsync(x => x.ResourceTitle == termsId))
|
||||||
|
.Select(x => x.Language);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check Has Terms and Conditions based on Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language">if null, used Default Language ...</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> HasTerms(string language = null)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
if (language.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
language = appConfiguration.DefaultLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
var result = !(await GetString(language: language))
|
||||||
|
.IsNullOrDefault();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve Terms and Conditions for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language">if null, used Default Language ...</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> GetTerms(string language = null)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var result = string.Empty;
|
||||||
|
var entity = await GetString(language: language);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!entity.IsNullOrDefault())
|
||||||
|
{
|
||||||
|
result = entity.TranslatedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add Terms and Conditions for Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="terms"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove Terms and Conditions of Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update Terms and Conditions of Specified Language ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <param name="terms"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> 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 ...
|
||||||
|
/// <summary>
|
||||||
|
/// Send Custom Push Message ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
/// <param name="payLoad"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task SendPush(
|
||||||
|
string action,
|
||||||
|
string payLoad,
|
||||||
|
string connectionId = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
var actions = new List<string>
|
||||||
|
{
|
||||||
|
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 ...
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve Terms and Conditions XString Entity ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="language"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<XString> 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
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<XBaseHub> logger) : base(logger)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Hub Actions ...
|
||||||
|
/// <summary>
|
||||||
|
/// Add Specified Terms and Conditions ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deleted Specified Terms and Conditions ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notify an Entity Updated ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="nuget" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
|
<add key="baget" value="https://nuget.saherelmhub.ir/v3/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<!-- Runtime Definition -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<LangVersion>8.0</LangVersion>
|
||||||
|
<PackageId>xSaherelmAI.xServices</PackageId>
|
||||||
|
<Authors>Hadi Khazaee Asl</Authors>
|
||||||
|
<Company>SaherElm IT Center</Company>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<Description>
|
||||||
|
it is a Part of xSaherElm AI project which integrated and implements all Required Services ...
|
||||||
|
</Description>
|
||||||
|
|
||||||
|
<!-- Icon Definition -->
|
||||||
|
<PackageIcon>icon.png</PackageIcon>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Icon Handling -->
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="../../Documents/Resources/Images/favicon.png" Link="icon.png" Pack="true"
|
||||||
|
PackagePath="\icon.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Local Modules -->
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="xDashboard.xMessageService" Version="1.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Project Dependencies -->
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\xDataHelper\xDataHelper.csproj" />
|
||||||
|
<ProjectReference Include="..\xIdentityHelper\xIdentityHelper.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user