From b5ad67c0c54483072c03bd4130174dd162b99bc2 Mon Sep 17 00:00:00 2001 From: Ali Yousefi Date: Mon, 25 Dec 2023 22:15:45 +0330 Subject: [PATCH 1/2] fix bug --- .../Helpers/ContentLanguageHelper.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Clients/Helpers/ContentLanguageHelper.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.Clients/Helpers/ContentLanguageHelper.cs index 081122b..98a70a2 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Clients/Helpers/ContentLanguageHelper.cs +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.Clients/Helpers/ContentLanguageHelper.cs @@ -180,15 +180,14 @@ public Task AddToContentLanguage(object item) /// /// /// - public async Task> AddToContentLanguage(IEnumerable items) + public Task>> AddToContentLanguage(IEnumerable items) { List> tasks = new List>(); foreach (var item in items) { tasks.Add(AddToContentLanguage(item)); } - await Task.WhenAll(tasks); - return tasks.Select(x => x.Result).ToList(); + return Task.FromResult(tasks); } /// From 8261f7677021fc29d6e28884cf9b311572ce27f3 Mon Sep 17 00:00:00 2001 From: Ali Yousefi Date: Mon, 25 Dec 2023 22:15:53 +0330 Subject: [PATCH 2/2] update core strucutre --- ...rvices.ContentsMicroservice.Clients.csproj | 2 +- ...ervices.ContentsMicroservice.Domain.csproj | 2 +- .../DatabaseBuilder.cs | 9 +++--- ...rvices.ContentsMicroservice.StartUp.csproj | 1 - ...services.ContentsMicroservice.Tests.csproj | 2 +- ...ervices.ContentsMicroservice.WebApi.csproj | 8 ++++- .../Program.cs | 4 +-- .../appsettings.json | 32 ++++++++++++------- 8 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Clients/EasyMicroservices.ContentsMicroservice.Clients.csproj b/src/CSharp/EasyMicroservices.ContentsMicroservice.Clients/EasyMicroservices.ContentsMicroservice.Clients.csproj index 5c1bf06..c556dbc 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Clients/EasyMicroservices.ContentsMicroservice.Clients.csproj +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.Clients/EasyMicroservices.ContentsMicroservice.Clients.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.21 + 0.0.0.22 client generated code. EasyMicroservices@gmail.com microservice,Content,Contents,client diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Domain/EasyMicroservices.ContentsMicroservice.Domain.csproj b/src/CSharp/EasyMicroservices.ContentsMicroservice.Domain/EasyMicroservices.ContentsMicroservice.Domain.csproj index d6228a2..1ab11f7 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Domain/EasyMicroservices.ContentsMicroservice.Domain.csproj +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.Domain/EasyMicroservices.ContentsMicroservice.Domain.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs index 8809e87..3715110 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/DatabaseBuilder.cs @@ -10,11 +10,12 @@ public DatabaseBuilder(IConfiguration configuration) : base(configuration) { } - public override void OnConfiguring(DbContextOptionsBuilder optionsBuilder, string name) + public override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - if (name == "SqlServer") - optionsBuilder.UseSqlServer(Configuration.GetConnectionString("local")); - else + var entity = GetEntity(); + if (entity.IsSqlServer()) + optionsBuilder.UseSqlServer(entity.ConnectionString); + else if (entity.IsInMemory()) optionsBuilder.UseInMemoryDatabase("Contents"); } } diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/EasyMicroservices.ContentsMicroservice.StartUp.csproj b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/EasyMicroservices.ContentsMicroservice.StartUp.csproj index eadaff3..3b2f750 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/EasyMicroservices.ContentsMicroservice.StartUp.csproj +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.StartUp/EasyMicroservices.ContentsMicroservice.StartUp.csproj @@ -6,7 +6,6 @@ - diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/EasyMicroservices.ContentsMicroservice.Tests.csproj b/src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/EasyMicroservices.ContentsMicroservice.Tests.csproj index fce63d4..57c83ed 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/EasyMicroservices.ContentsMicroservice.Tests.csproj +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.Tests/EasyMicroservices.ContentsMicroservice.Tests.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/EasyMicroservices.ContentsMicroservice.WebApi.csproj b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/EasyMicroservices.ContentsMicroservice.WebApi.csproj index af0adea..20453b0 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/EasyMicroservices.ContentsMicroservice.WebApi.csproj +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/EasyMicroservices.ContentsMicroservice.WebApi.csproj @@ -23,5 +23,11 @@ - + + + + + + + diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/Program.cs b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/Program.cs index 1094303..cd54dd1 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/Program.cs +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/Program.cs @@ -17,12 +17,10 @@ public static async Task Main(string[] args) static WebApplicationBuilder CreateBuilder(string[] args) { var app = StartUpExtensions.Create(args); - app.Services.Builder(); + app.Services.Builder("Content"); app.Services.AddTransient((serviceProvider) => new UnitOfWork(serviceProvider)); app.Services.AddTransient(serviceProvider => new ContentContext(serviceProvider.GetService())); app.Services.AddTransient(); - StartUpExtensions.AddAuthentication("RootAddresses:Authentication"); - StartUpExtensions.AddWhiteLabel("Content", "RootAddresses:WhiteLabel"); return app; } diff --git a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json index b5586bb..8e58937 100644 --- a/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json +++ b/src/CSharp/EasyMicroservices.ContentsMicroservice.WebApi/appsettings.json @@ -6,25 +6,33 @@ } }, "AllowedHosts": "*", - "ConnectionStrings": { - "local": "Server=.;Database=Contents;User ID=TrustServerCertificate=True;" - }, - "Database": { - "ProviderName": "InMemory" - }, + "Databases": [ + { + "Name": "Entity", + "ProviderName": "InMemory", + "ConnectionString": "Server=.;Database=Contents;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True" + } + ], + "ServiceAddresses": [ + { + "Name": "Authentication", + "Address": "http://localhost:1044", + "Databases": null + }, + { + "Name": "WhiteLabel", + "Address": "http://localhost:1041", + "Databases": null + } + ], "Authorization": { - "Use": false, + "Use": true, "JWT": { "Key": "VGhpc0lzGHGHGHlY3JldEtleUZvckp3dEF1dGhlbnRpY2F0aW9u=", "Issuer": "https://github.com/easymicroservices", "Audience": "easymicroservices", - "TokenExpireTimeInSeconds": 86400 } }, - "RootAddresses": { - "WhiteLabel": "http://localhost:1041", - "Authentication": "http://localhost:1044" - }, "Urls": "http://*:2003" } \ No newline at end of file