From 9cf656c85417ed2799a538e24024bed2bd004935 Mon Sep 17 00:00:00 2001 From: Anders Revsgaard Date: Tue, 26 Nov 2024 15:29:16 +0100 Subject: [PATCH] Client, add catch TokenUnavailableException in SetHourPrice method. --- src/FoxIDs.Control/FoxIDs.Control.csproj | 2 +- .../FoxIDs.ControlClient.csproj | 2 +- src/FoxIDs.ControlClient/Pages/Usage/Usage.cs | 19 +++++++++++++------ .../FoxIDs.ControlShared.csproj | 2 +- src/FoxIDs.Shared/FoxIDs.Shared.csproj | 2 +- .../FoxIDs.SharedBase.csproj | 2 +- src/FoxIDs/FoxIDs.csproj | 2 +- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/FoxIDs.Control/FoxIDs.Control.csproj b/src/FoxIDs.Control/FoxIDs.Control.csproj index ae0ce3fb..4b935746 100644 --- a/src/FoxIDs.Control/FoxIDs.Control.csproj +++ b/src/FoxIDs.Control/FoxIDs.Control.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.7 + 1.12.8 FoxIDs Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj b/src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj index 6e0e99c4..df86875c 100644 --- a/src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj +++ b/src/FoxIDs.ControlClient/FoxIDs.ControlClient.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.7 + 1.12.8 FoxIDs.Client Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs.ControlClient/Pages/Usage/Usage.cs b/src/FoxIDs.ControlClient/Pages/Usage/Usage.cs index e916fab3..ec838421 100644 --- a/src/FoxIDs.ControlClient/Pages/Usage/Usage.cs +++ b/src/FoxIDs.ControlClient/Pages/Usage/Usage.cs @@ -249,15 +249,22 @@ private async Task UsedViewModelAfterInitAsync(GeneralUsedViewModel generalUsed, private async Task SetHourPrice(GeneralUsedViewModel generalUsed) { - var tenant = await TenantService.GetTenantAsync(generalUsed.TenantName); - if (tenant.HourPrice > 0) + try { - generalUsed.HourPrice = tenant.HourPrice.Value; + var tenant = await TenantService.GetTenantAsync(generalUsed.TenantName); + if (tenant.HourPrice > 0) + { + generalUsed.HourPrice = tenant.HourPrice.Value; + } + else + { + var rate = GetExchangesRate(tenant.Currency, usageSettings.CurrencyExchanges); + generalUsed.HourPrice = decimal.Round(usageSettings.HourPrice * rate, 2); + } } - else + catch (TokenUnavailableException) { - var rate = GetExchangesRate(tenant.Currency, usageSettings.CurrencyExchanges); - generalUsed.HourPrice = decimal.Round(usageSettings.HourPrice * rate, 2); + await (OpenidConnectPkce as TenantOpenidConnectPkce).TenantLoginAsync(); } } diff --git a/src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj b/src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj index eb40b81f..b6fb6034 100644 --- a/src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj +++ b/src/FoxIDs.ControlShared/FoxIDs.ControlShared.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.7 + 1.12.8 FoxIDs Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs.Shared/FoxIDs.Shared.csproj b/src/FoxIDs.Shared/FoxIDs.Shared.csproj index cb35cbf1..ae1a93be 100644 --- a/src/FoxIDs.Shared/FoxIDs.Shared.csproj +++ b/src/FoxIDs.Shared/FoxIDs.Shared.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.7 + 1.12.8 FoxIDs Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj b/src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj index 61a051f5..7e767c16 100644 --- a/src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj +++ b/src/FoxIDs.SharedBase/FoxIDs.SharedBase.csproj @@ -2,7 +2,7 @@ net8.0 - 1.12.7 + 1.12.8 FoxIDs Anders Revsgaard ITfoxtec diff --git a/src/FoxIDs/FoxIDs.csproj b/src/FoxIDs/FoxIDs.csproj index 137b3860..2b1c03d3 100644 --- a/src/FoxIDs/FoxIDs.csproj +++ b/src/FoxIDs/FoxIDs.csproj @@ -1,7 +1,7 @@  net8.0 - 1.12.7 + 1.12.8 FoxIDs Anders Revsgaard ITfoxtec