From e0ec864d3a4430d2f50d4aeab0b04dfe263a274e Mon Sep 17 00:00:00 2001 From: Anders Revsgaard Date: Wed, 27 Nov 2024 10:49:46 +0100 Subject: [PATCH] Usage error if not custom domain, resolved --- .../Tenants/TMyTenantController.cs | 2 +- src/FoxIDs.Control/FoxIDs.Control.csproj | 2 +- .../FoxIDs.ControlClient.csproj | 2 +- .../Logic/RouteBindingLogic.cs | 23 +++++-------------- .../ViewModels/Tenants/TenantViewModel.cs | 2 +- .../Pages/MasterTenant.cs | 12 ++++++++-- .../FoxIDs.ControlShared.csproj | 2 +- src/FoxIDs.Shared/FoxIDs.Shared.csproj | 2 +- .../FoxIDs.SharedBase.csproj | 2 +- src/FoxIDs/FoxIDs.csproj | 2 +- 10 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/FoxIDs.Control/Controllers/Tenants/TMyTenantController.cs b/src/FoxIDs.Control/Controllers/Tenants/TMyTenantController.cs index 131d2bd1e..aba1a2acc 100644 --- a/src/FoxIDs.Control/Controllers/Tenants/TMyTenantController.cs +++ b/src/FoxIDs.Control/Controllers/Tenants/TMyTenantController.cs @@ -116,7 +116,7 @@ public TMyTenantController(FoxIDsControlSettings settings, TelemetryScopedLogger logger.Error(exp, "Unable to update plan in tenant."); } - if(!mTenant.CustomDomain.Equals(tenant.CustomDomain, StringComparison.OrdinalIgnoreCase)) + if(mTenant.CustomDomain.IsNullOrEmpty() || !mTenant.CustomDomain.Equals(tenant.CustomDomain, StringComparison.OrdinalIgnoreCase)) { mTenant.CustomDomain = tenant.CustomDomain?.ToLower(); mTenant.CustomDomainVerified = false; diff --git a/src/FoxIDs.Control/FoxIDs.Control.csproj b/src/FoxIDs.Control/FoxIDs.Control.csproj index 4b9357469..0ffb3b0a7 100644 --- a/src/FoxIDs.Control/FoxIDs.Control.csproj +++ b/src/FoxIDs.Control/FoxIDs.Control.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.8 + 1.12.9 FoxIDs Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj b/src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj index df86875c6..28b96ea2f 100644 --- a/src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj +++ b/src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.8 + 1.12.9 FoxIDs.Client Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs.ControlClient/Logic/RouteBindingLogic.cs b/src/FoxIDs.ControlClient/Logic/RouteBindingLogic.cs index 5beb79fcb..32bd2295f 100644 --- a/src/FoxIDs.ControlClient/Logic/RouteBindingLogic.cs +++ b/src/FoxIDs.ControlClient/Logic/RouteBindingLogic.cs @@ -44,32 +44,21 @@ public RouteBindingLogic(ClientSettings clientSettings, IServiceProvider service public bool RequestPayment { get; private set; } - public async Task SetMyTenantAsync(TenantResponse tenant) + public void SetMyTenant(TenantResponse tenant) { myTenant = tenant; if (!IsMasterTenant && clientSettings.EnablePayment) { - await UpdatRequestPaymentAsync(myTenant); + UpdatRequestPayment(myTenant); } } - private async Task UpdatRequestPaymentAsync(TenantResponse myTenant) + private void UpdatRequestPayment(TenantResponse myTenant) { - if (myTenant.EnableUsage && myTenant.DoPayment && !myTenant.PlanName.IsNullOrEmpty() && "free" != myTenant.PlanName && myTenant.Payment?.IsActive != true) + if (myTenant.DoPayment && myTenant.Payment?.IsActive != true) { - var helpersService = serviceProvider.GetService(); - var planInfoList = await helpersService.GetPlanInfoAsync(); - - decimal planCost = planInfoList.Where(p => p.Name == myTenant.PlanName).Select(p => p.CostPerMonth).FirstOrDefault(); - if (planCost > 0) - { - RequestPayment = true; - } - else - { - RequestPayment = false; - } + RequestPayment = true; } else { @@ -152,7 +141,7 @@ private async Task LoadMyTenantAsync() if (authenticationState.User.Identity.IsAuthenticated && !IsMasterTenant) { var myTenantService = serviceProvider.GetService(); - await SetMyTenantAsync(await myTenantService.GetTenantAsync()); + SetMyTenant(await myTenantService.GetTenantAsync()); } } } diff --git a/src/FoxIDs.ControlClient/Models/ViewModels/Tenants/TenantViewModel.cs b/src/FoxIDs.ControlClient/Models/ViewModels/Tenants/TenantViewModel.cs index 1d8cc40bf..13b3fa37b 100644 --- a/src/FoxIDs.ControlClient/Models/ViewModels/Tenants/TenantViewModel.cs +++ b/src/FoxIDs.ControlClient/Models/ViewModels/Tenants/TenantViewModel.cs @@ -23,7 +23,7 @@ public class TenantViewModel [Display(Name = "Enable usage")] public bool EnableUsage { get; set; } - [Display(Name = "Do payment")] + [Display(Name = "Do card payment")] public bool DoPayment { get; set; } /// diff --git a/src/FoxIDs.ControlClient/Pages/MasterTenant.cs b/src/FoxIDs.ControlClient/Pages/MasterTenant.cs index 230d4c7e4..1c180ca96 100644 --- a/src/FoxIDs.ControlClient/Pages/MasterTenant.cs +++ b/src/FoxIDs.ControlClient/Pages/MasterTenant.cs @@ -57,6 +57,9 @@ public partial class MasterTenant [Inject] public MyTenantService MyTenantService { get; set; } + [Inject] + public TrackService TrackService { get; set; } + [Parameter] public string TenantName { get; set; } @@ -77,6 +80,11 @@ protected override async Task OnInitializedAsync() TrackSelectedLogic.OnTrackSelectedAsync += OnTrackSelectedAsync; NotificationLogic.OnClientSettingLoaded += OnClientSettingLoaded; NotificationLogic.OnOpenPaymentMethodAsync += OnOpenPaymentMethodAsync; + if (TrackSelectedLogic.Track.Name != Constants.Routes.MasterTrackName) + { + var masterTrack = await TrackService.GetTrackAsync(Constants.Routes.MasterTrackName); + await TrackSelectedLogic.TrackSelectedAsync(masterTrack); + } if (TrackSelectedLogic.IsTrackSelected) { await DefaultLoadAsync(); @@ -110,7 +118,7 @@ private async Task DefaultLoadAsync() deleteTenantAcknowledge = false; myTenant = await MyTenantService.GetTenantAsync(); - await RouteBindingLogic.SetMyTenantAsync(myTenant); + RouteBindingLogic.SetMyTenant(myTenant); savedCustomDomain = myTenant.CustomDomain; @@ -146,7 +154,7 @@ private async Task OnUpdateTenantValidSubmitAsync(EditContext editContext) savedCustomDomain = myTenant.CustomDomain; tenantSettingsForm.Model.CustomDomain = myTenant.CustomDomain; tenantSettingsForm.Model.CustomDomainVerified = myTenant.CustomDomainVerified; - await RouteBindingLogic.SetMyTenantAsync(myTenant); + RouteBindingLogic.SetMyTenant(myTenant); tenantWorking = false; } catch (Exception ex) diff --git a/src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj b/src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj index b6fb60342..d6a6cb9a2 100644 --- a/src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj +++ b/src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.8 + 1.12.9 FoxIDs Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs.Shared/FoxIDs.Shared.csproj b/src/FoxIDs.Shared/FoxIDs.Shared.csproj index ae1a93be2..1015cf93a 100644 --- a/src/FoxIDs.Shared/FoxIDs.Shared.csproj +++ b/src/FoxIDs.Shared/FoxIDs.Shared.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.8 + 1.12.9 FoxIDs Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj b/src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj index 7e767c16f..ebe320b31 100644 --- a/src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj +++ b/src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.8 + 1.12.9 FoxIDs Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs/FoxIDs.csproj b/src/FoxIDs/FoxIDs.csproj index 2b1c03d3f..eec4fe30c 100644 --- a/src/FoxIDs/FoxIDs.csproj +++ b/src/FoxIDs/FoxIDs.csproj @@ -1,7 +1,7 @@  net8.0 - 1.12.8 + 1.12.9 FoxIDs Anders Revsgaard ITfoxtec