diff --git a/Base/XIBaseV1EntityController.cs b/Base/XIBaseV1EntityController.cs index 843ecd2..617718a 100644 --- a/Base/XIBaseV1EntityController.cs +++ b/Base/XIBaseV1EntityController.cs @@ -16,105 +16,107 @@ using xPushService.Constants; namespace xApi.Base { - [ApiController] - [ApiVersion("1.0")] - [RequireXPowered(true)] - [Route("api/v{version:apiVersion}/entities/[controller]")] - public abstract class XIBaseV1EntityController : XIBaseEntityController - where TEntity : XBaseEntity - { - // - #region Constructor ... - protected XIBaseV1EntityController( - ILogger> logger, - XAppConfiguration appConfiguration, - IXIdentityProvider identityProvider, - XValidationProvider validationProvider, - IXBaseRepository repository - ) : base( - logger, - appConfiguration, - identityProvider, - validationProvider, - repository - ) - { } - #endregion - } + // + // TODO: Fix this ... + // [ApiController] + // [ApiVersion("1.0")] + // [RequireXPowered(true)] + // [Route("api/v{version:apiVersion}/entities/[controller]")] + // public abstract class XIBaseV1EntityController : XIBaseEntityController + // where TEntity : XBaseEntity + // { + // // + // #region Constructor ... + // protected XIBaseV1EntityController( + // ILogger> logger, + // XAppConfiguration appConfiguration, + // IXIdentityProvider identityProvider, + // XValidationProvider validationProvider, + // IXBaseRepository repository + // ) : base( + // logger, + // appConfiguration, + // identityProvider, + // validationProvider, + // repository + // ) + // { } + // #endregion + // } - public abstract class XIBaseV1EntityHubController : XIBaseV1EntityController - where TEntity : XBaseEntity - { - // - #region Props ... - public IHubContext> Hub { get; } - #endregion + // public abstract class XIBaseV1EntityHubController : XIBaseV1EntityController + // where TEntity : XBaseEntity + // { + // // + // #region Props ... + // public IHubContext> Hub { get; } + // #endregion - // - #region Constructor ... - protected XIBaseV1EntityHubController( - ILogger> logger, - XAppConfiguration appConfiguration, - IXIdentityProvider identityProvider, - XValidationProvider validationProvider, - IXBaseRepository repository, - IHubContext> hub = null - ) : base( - logger, - appConfiguration, - identityProvider, - validationProvider, - repository - ) - { - Hub = hub; - } - #endregion + // // + // #region Constructor ... + // protected XIBaseV1EntityHubController( + // ILogger> logger, + // XAppConfiguration appConfiguration, + // IXIdentityProvider identityProvider, + // XValidationProvider validationProvider, + // IXBaseRepository repository, + // IHubContext> hub = null + // ) : base( + // logger, + // appConfiguration, + // identityProvider, + // validationProvider, + // repository + // ) + // { + // Hub = hub; + // } + // #endregion - // - #region Hub ... - [NonAction] - public async Task SendPush( - string action, - string payLoad - ) - { - // - var actions = new List - { - XBaseEntityHubAction.Add.GetStringValue(), - XBaseEntityHubAction.Update.GetStringValue(), - XBaseEntityHubAction.Delete.GetStringValue(), - XBaseEntityHubAction.AddMany.GetStringValue(), - XBaseEntityHubAction.DeleteMany.GetStringValue(), - XBaseEntityHubAction.UpdateMany.GetStringValue(), - XBaseEntityHubAction.AddOrUpdate.GetStringValue(), - }; + // // + // #region Hub ... + // [NonAction] + // public async Task SendPush( + // string action, + // string payLoad + // ) + // { + // // + // var actions = new List + // { + // XBaseEntityHubAction.Add.GetStringValue(), + // XBaseEntityHubAction.Update.GetStringValue(), + // XBaseEntityHubAction.Delete.GetStringValue(), + // XBaseEntityHubAction.AddMany.GetStringValue(), + // XBaseEntityHubAction.DeleteMany.GetStringValue(), + // XBaseEntityHubAction.UpdateMany.GetStringValue(), + // XBaseEntityHubAction.AddOrUpdate.GetStringValue(), + // }; - // - // Validate ... - var isValid = - !Hub.IsNull() && - !action.IsNullOrEmpty() && - !payLoad.IsNullOrEmpty() && - actions.Contains(action); - if (!isValid) - { - return; - } + // // + // // Validate ... + // var isValid = + // !Hub.IsNull() && + // !action.IsNullOrEmpty() && + // !payLoad.IsNullOrEmpty() && + // actions.Contains(action); + // if (!isValid) + // { + // return; + // } - // - // Retrieve Connection Id ... - var connectionId = GetConnectionId(); - var clients = Hub.Clients.All; - if (!connectionId.IsNullOrEmpty()) - { - clients = Hub.Clients.AllExcept(connectionId); - } + // // + // // Retrieve Connection Id ... + // var connectionId = GetConnectionId(); + // var clients = Hub.Clients.All; + // if (!connectionId.IsNullOrEmpty()) + // { + // clients = Hub.Clients.AllExcept(connectionId); + // } - // - await clients.SendAsync(action, payLoad, connectionId); - } - #endregion - } + // // + // await clients.SendAsync(action, payLoad, connectionId); + // } + // #endregion + // } } \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index 4bd0cdb..15cabbc 100644 --- a/Startup.cs +++ b/Startup.cs @@ -1,11 +1,11 @@ using System; +using System.Collections.Generic; using System.IO; using System.Net.Http; using System.Reflection; using IdentityModel.AspNetCore.OAuth2Introspection; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -15,10 +15,11 @@ using Newtonsoft.Json.Serialization; using xApi.Extensions; using xCommons.Configurations; using xCommons.Extensions; -using xDataService.DI; +using xDataService.Models; using xHttpService.DI; using xIdentityService.DI; using xServices.Databases; +using xServices.DI; namespace xApi { @@ -32,6 +33,9 @@ namespace xApi { // Configuration = configuration; + + // + // Create an Api Descriptor Class Instance ... apiDatabaseDescriptor = new XApiDatabaseDescriptor(); } @@ -61,24 +65,8 @@ namespace xApi services.AddXHttpService(Configuration); // - // Register Api Versioning ... - services.AddApiVersioning(opt => - { - // - // Set Default Api Version ... - opt.DefaultApiVersion = new ApiVersion(1, 0); - - // - // Set Routing to Default API Version, if Version unspecified ... - opt.AssumeDefaultVersionWhenUnspecified = true; - - // - // Report All Available Api Versions on Response ... - opt.ReportApiVersions = true; - }); - - // - var lifeTime = ServiceLifetime.Scoped; + // Add Api V1 Versioning ... + services.AddXApiV1Versioning(); // // OAuthIntrospectin Http Client Handler ... @@ -120,26 +108,22 @@ namespace xApi }); // - // Check Data Service ... - var dataServiceConfig = Configuration.GetXDataServiceConfiguration(); - - // - // Check DataBase Registration ... - services.AddXDatabase( - lifetime: lifeTime, + // Register Services ... + services.AddXServices( configuration: Configuration, - descriptor: apiDatabaseDescriptor + databases: new List + { + apiDatabaseDescriptor + }, + lifeTime: ServiceLifetime.Scoped ); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // - var withPlayground = false; if (env.IsDevelopment()) { - // - withPlayground = true; app.UseDeveloperExceptionPage(); } @@ -181,18 +165,13 @@ namespace xApi // // Use xDataService Middleware ... - app.UseXDatabase( - descriptor: apiDatabaseDescriptor, + app.UseXServices( + databases: new List + { + apiDatabaseDescriptor + }, isDevelopmentEnvironment: env.IsDevelopment() ); - - // - // Using Services ... - // app.UseXServices(); - - // - // Use xGraphQL Middleware ... - // app.UseXGraphQL(withPlayground: withPlayground); } } } \ No newline at end of file diff --git a/appsettings.json b/appsettings.json index de6af52..286a34d 100644 --- a/appsettings.json +++ b/appsettings.json @@ -70,7 +70,7 @@ } }, "EnableTracking": true, - "EnableSoftDelete": false, + "EnableSoftDelete": true, "EnableDetailedErrors": false, "SeedingMode": "AddIfNotExists", "EnableSensitiveDataLogging": true, @@ -81,22 +81,6 @@ }, "GraphQLBasePath": "/graphs" }, - "DbSeeder": { - "UpdateExists": false, - "Strings": [], - "Terms": [ - { - "Language": "fa-IR", - "ResourceTitle": "terms", - "TranslatedValue": "توافقنامه استفاده از خدمات و شرایط و ضوابط عضویت" - }, - { - "Language": "en-US", - "ResourceTitle": "terms", - "TranslatedValue": "Terms and Conditions of Using Yuze Services" - } - ] - }, "HttpServiceConfiguration": { "DisableSSLCheck": true, "DefaultClientTimeout": -1