119 lines
3.4 KiB
Markdown
119 lines
3.4 KiB
Markdown
# xTermsAndConditionsService
|
|
|
|
it is a Part of xDashboard on SaherElm IT Center which provides Terms and Conditions Management Futures ...
|
|
|
|
this module has following dependencies :
|
|
|
|
- **xStringService**
|
|
|
|
for configure and use this Module refer to DI.XDIHelperExtension.cs file.
|
|
|
|
## Providers
|
|
|
|
in this module all requirements tools for manage Terms and Conditions Integrated and Provided.
|
|
|
|
- **IXTermsAndComditionsProvider**: an Interface for Describe Provided Actions for Terms and Conditions Management.
|
|
- **XTermsAndComditionsProvider**: an Implementation of Provided Actions for Terms and Conditions Management.
|
|
- **XTermsHub**: a Hub Implementation for Notifing Terms Changes to Connected Clients.
|
|
- **IXTermsAndComditionsController**: an Interface for Describe base Terms and Conditions Management Controller Actions.
|
|
- **XTermsAndComditionsControllerBase**: an Abstract Base Implementation of base Terms and Conditions Management Controller Actions.
|
|
|
|
## Implementation
|
|
|
|
you have to follow these steps for using this Module.
|
|
|
|
### Configure Service
|
|
|
|
all of Requirements for Terms and Conditions must be Configured using appSettings and provided by IConfiguration to Modules.
|
|
|
|
fo using Service you Have to Configure the Service in you appSettings.json file.
|
|
|
|
this configurations mapped to **XTermsAndConditionsServiceConfiguration** class.
|
|
|
|
```C#
|
|
/// <summary>
|
|
/// Terms and Conditions Configuration ...
|
|
/// </summary>
|
|
public class XTermsAndConditionsServiceConfiguration
|
|
{
|
|
/// <summary>
|
|
/// Terms And Conditions Resource Title in XString Table ...
|
|
/// </summary>
|
|
public string ResourceTitle { get; set; } = "terms_and_conditions";
|
|
|
|
/// <summary>
|
|
/// Seeding Mode for Terms and Conditions ...
|
|
/// </summary>
|
|
public XDbSeedingMode SeedingMode { get; set; } = XDbSeedingMode.AddIfNotExists;
|
|
|
|
/// <summary>
|
|
/// Default Terms and Conditions for Add to Databse on App Startup ...
|
|
/// </summary>
|
|
public List<XStringDto> TermsAndConditions { get; set; } = null;
|
|
}
|
|
```
|
|
|
|
a sample Configuration must like this:
|
|
|
|
```json
|
|
{
|
|
...
|
|
"TermsAndConditionsService": {
|
|
"ResourceTitle": "terms_and_conditions",
|
|
"SeedingMode": "AddIfNotExists",
|
|
"TermsAndConditions": [
|
|
{
|
|
"Language": "fa-IR",
|
|
"TranslatedValue": "شرایط و ضوابط ثبت نام در سامانه"
|
|
}
|
|
]
|
|
},
|
|
...
|
|
}
|
|
```
|
|
|
|
### Register Service
|
|
|
|
after preparation of all requirements, final steps is Register Service.
|
|
|
|
there are two main step:
|
|
|
|
- **DI Registration**: in this phase, all Provided Services Registered in DI.
|
|
- **Middleware Usage**: in this phase, if any Terms and Conditions Provided in Configuration, Seeded in Data Persist System using Provided Services.
|
|
|
|
```C#
|
|
public class Startup
|
|
{
|
|
//
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
...
|
|
//
|
|
// Register Terms and Conditions Service ...
|
|
services.AddXTermsConditionsService(
|
|
lifeTime: lifeTime,
|
|
configuration: configuration
|
|
);
|
|
...
|
|
}
|
|
|
|
//
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
...
|
|
//
|
|
// Using Terms and Conditions Service ...
|
|
app.UseXTermsAndConditionsService();
|
|
...
|
|
}
|
|
}
|
|
```
|
|
|
|
## Maintainer
|
|
|
|
Hadi Khazaee asl
|
|
|
|
[https://www.saherelm.ir](https://www.saherelm.ir)
|
|
|
|
[hadi_khazaee_asl@yahoo.com](mailto:hadi_khazaee_asl@yahoo.com)
|