From 6f2126373aa93ce841c1345aea9cd6a51696f8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Fri, 12 Jul 2024 15:29:19 +0200 Subject: [PATCH 1/5] Adapting IOrchardCoreApi.SetupAsync() to OC API changes --- Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs | 4 +++- Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs b/Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs index 2535c19..b799931 100644 --- a/Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs +++ b/Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs @@ -30,7 +30,9 @@ public interface IOrchardCoreApi /// The response of the tenant setup. [Post("/api/tenants/setup")] [Headers(AuthorizationBearer, RequestedWithXmlHttpRequest)] - Task> SetupAsync([Body(buffered: true)] TenantSetupApiModel setupTenantParameters); + Task> SetupAsync( + [Body(buffered: true)] TenantSetupApiModel setupTenantParameters, + [AliasAs("recipe")] StreamPart recipe = null); /// /// Edit a previously created tenant in Orchard Core. diff --git a/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs b/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs index 8d823d0..c45bb57 100644 --- a/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs +++ b/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs @@ -1,6 +1,4 @@ using System.ComponentModel.DataAnnotations; -using System.Text.Json.Nodes; -using System.Text.Json.Serialization; namespace Lombiq.OrchardCoreApiClient.Models; @@ -25,8 +23,6 @@ public class TenantSetupApiModel public string Password { get; set; } public string RecipeName { get; set; } - [JsonPropertyName("Recipe")] - public JsonNode RecipeJson { get; set; } - public string SiteTimeZone { get; set; } + public string Schema { get; set; } } From 650bd8f7f1bd1c9798770b2d893ba642cbc7477a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Fri, 12 Jul 2024 15:30:09 +0200 Subject: [PATCH 2/5] Fixing that the setup operation didn't throw if it failed --- Lombiq.OrchardCoreApiClient/ApiClient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lombiq.OrchardCoreApiClient/ApiClient.cs b/Lombiq.OrchardCoreApiClient/ApiClient.cs index a91855b..c4094ef 100644 --- a/Lombiq.OrchardCoreApiClient/ApiClient.cs +++ b/Lombiq.OrchardCoreApiClient/ApiClient.cs @@ -95,7 +95,8 @@ public async Task CreateAndSetupTenantAsync( try { - await OrchardCoreApi.SetupAsync(setupApiViewModel).ConfigureAwait(false); + using var response = await OrchardCoreApi.SetupAsync(setupApiViewModel).ConfigureAwait(false); + await response.EnsureSuccessStatusCodeAsync(); } catch (ApiException ex) { From 6cff02df523761af715de7af451c17628e736bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Sun, 14 Jul 2024 00:33:54 +0200 Subject: [PATCH 3/5] Reverting to the original implementation --- Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs | 4 +--- Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs b/Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs index b799931..2535c19 100644 --- a/Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs +++ b/Lombiq.OrchardCoreApiClient/Interfaces/IOrchardCoreApi.cs @@ -30,9 +30,7 @@ public interface IOrchardCoreApi /// The response of the tenant setup. [Post("/api/tenants/setup")] [Headers(AuthorizationBearer, RequestedWithXmlHttpRequest)] - Task> SetupAsync( - [Body(buffered: true)] TenantSetupApiModel setupTenantParameters, - [AliasAs("recipe")] StreamPart recipe = null); + Task> SetupAsync([Body(buffered: true)] TenantSetupApiModel setupTenantParameters); /// /// Edit a previously created tenant in Orchard Core. diff --git a/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs b/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs index c45bb57..8d823d0 100644 --- a/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs +++ b/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs @@ -1,4 +1,6 @@ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; namespace Lombiq.OrchardCoreApiClient.Models; @@ -23,6 +25,8 @@ public class TenantSetupApiModel public string Password { get; set; } public string RecipeName { get; set; } + [JsonPropertyName("Recipe")] + public JsonNode RecipeJson { get; set; } + public string SiteTimeZone { get; set; } - public string Schema { get; set; } } From ccce0cf1ef7d0e312ced3c6503d71c63dc73e51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Sun, 14 Jul 2024 00:35:41 +0200 Subject: [PATCH 4/5] Adding missing Schema property for the setup --- Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs b/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs index 8d823d0..b07b76b 100644 --- a/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs +++ b/Lombiq.OrchardCoreApiClient/Models/TenantSetupApiModel.cs @@ -14,6 +14,7 @@ public class TenantSetupApiModel public string DatabaseProvider { get; set; } public string ConnectionString { get; set; } public string TablePrefix { get; set; } + public string Schema { get; set; } [Required] public string UserName { get; set; } From 57e1da7c3be9dbc3e041d373eb632a35b7ca35d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Sun, 14 Jul 2024 00:36:55 +0200 Subject: [PATCH 5/5] Removing unnecessary second recipe assignment --- Lombiq.OrchardCoreApiClient.Tester/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Lombiq.OrchardCoreApiClient.Tester/Program.cs b/Lombiq.OrchardCoreApiClient.Tester/Program.cs index eaad95a..6d77f53 100644 --- a/Lombiq.OrchardCoreApiClient.Tester/Program.cs +++ b/Lombiq.OrchardCoreApiClient.Tester/Program.cs @@ -47,7 +47,6 @@ await apiClient.CreateAndSetupTenantAsync( Name = name, DatabaseProvider = "Sqlite", ConnectionString = string.Empty, - RecipeName = "Blog", UserName = "admin", Email = "admin@example.com", Password = "Password1!",