Skip to content

Commit 9b2bd47

Browse files
perform null check
1 parent c7b844e commit 9b2bd47

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Umbraco.Commerce.Deploy/Connectors/ValueConnectors/UmbracoCommercePriceValueConnector.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,18 @@ public class UmbracoCommercePriceValueConnector(
7676

7777
var dstDict = new Dictionary<Guid, decimal?>();
7878

79-
foreach (KeyValuePair<string, decimal?> kvp in srcDict)
79+
if (srcDict != null)
8080
{
81-
if (UdiHelper.TryParseGuidUdi(kvp.Key, out GuidUdi? udi) && udi!.EntityType == UmbracoCommerceConstants.UdiEntityType.Currency)
81+
foreach (KeyValuePair<string, decimal?> kvp in srcDict)
8282
{
83-
CurrencyReadOnly? currencyEntity = await umbracoCommerceApi.GetCurrencyAsync(udi.Guid);
84-
if (currencyEntity != null)
83+
if (UdiHelper.TryParseGuidUdi(kvp.Key, out GuidUdi? udi) &&
84+
udi!.EntityType == UmbracoCommerceConstants.UdiEntityType.Currency)
8585
{
86-
dstDict.Add(currencyEntity.Id, kvp.Value);
86+
CurrencyReadOnly? currencyEntity = await umbracoCommerceApi.GetCurrencyAsync(udi.Guid);
87+
if (currencyEntity != null)
88+
{
89+
dstDict.Add(currencyEntity.Id, kvp.Value);
90+
}
8791
}
8892
}
8993
}

0 commit comments

Comments
 (0)