From 7269f0b72956603543bfbc450f02b884feaa1c0a Mon Sep 17 00:00:00 2001 From: Eric Nguyen Date: Thu, 9 Nov 2023 17:40:10 +0700 Subject: [PATCH] fix create new theme on import app --- .../mix.portal/Domain/Services/MixApplicationService.cs | 1 + src/platform/mix.library/Services/MixTenantService.cs | 3 +++ src/platform/mix.service/Models/MixTenantSystemModel.cs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/modules/mix.portal/Domain/Services/MixApplicationService.cs b/src/modules/mix.portal/Domain/Services/MixApplicationService.cs index 8cd18244e..08bc15728 100644 --- a/src/modules/mix.portal/Domain/Services/MixApplicationService.cs +++ b/src/modules/mix.portal/Domain/Services/MixApplicationService.cs @@ -149,6 +149,7 @@ private async Task ImportSchema(string schemaFolder, CancellationToken cancellat if (Directory.Exists(schemaFolder)) { var schema = await _importService.LoadSchema(schemaFolder); + schema.ThemeId = CurrentTenant.Themes.FirstOrDefault().Id; if (schema != null && schema.IsValid) { await _importService.ImportSelectedItemsAsync(schema); diff --git a/src/platform/mix.library/Services/MixTenantService.cs b/src/platform/mix.library/Services/MixTenantService.cs index f28e46eed..3b9bf3b9b 100644 --- a/src/platform/mix.library/Services/MixTenantService.cs +++ b/src/platform/mix.library/Services/MixTenantService.cs @@ -11,6 +11,7 @@ public sealed class MixTenantService : IMixTenantService public List AllTenants { get; set; } public List AllCultures { get; set; } + public List AllThemes { get; set; } public MixTenantService(DatabaseService databaseService) { @@ -29,6 +30,7 @@ public async Task Reload(CancellationToken cancellationToken = default) var domains = await dbContext.MixDomain.Where(p => tenantIds.Contains(p.MixTenantId)).ToListAsync(cancellationToken); AllCultures = await dbContext.MixCulture.ToListAsync(cancellationToken); + AllThemes = await dbContext.MixTheme.ToListAsync(cancellationToken); var tenants = mixTenants .Select(p => new MixTenantSystemModel @@ -41,6 +43,7 @@ public async Task Reload(CancellationToken cancellationToken = default) Configurations = new TenantConfigService(p.SystemName).AppSettings, Domains = domains.Where(d => d.MixTenantId == p.Id).ToList(), Cultures = AllCultures.Where(c => c.MixTenantId == p.Id).ToList(), + Themes = AllThemes.Where(c => c.MixTenantId == p.Id).ToList(), }) .ToList(); diff --git a/src/platform/mix.service/Models/MixTenantSystemModel.cs b/src/platform/mix.service/Models/MixTenantSystemModel.cs index a7e77713a..a50b41763 100644 --- a/src/platform/mix.service/Models/MixTenantSystemModel.cs +++ b/src/platform/mix.service/Models/MixTenantSystemModel.cs @@ -17,6 +17,7 @@ public class MixTenantSystemModel public List Domains { get; set; } public List Cultures { get; set; } = new(); + public List Themes { get; set; } = new(); public TenantConfigurationModel Configurations { get; set; } }