fix crash on not found perk items (#3685)

This commit is contained in:
Andrew Camilleri
2022-04-28 16:03:19 +02:00
committed by GitHub
parent ae67cc8a51
commit f7cb44c343

View File

@@ -214,11 +214,11 @@ namespace BTCPayServer.Services.Apps
return rate * value;
}));
var itemCode = entities.Key;
var perk = perks.First(p => p.Id == itemCode);
var perk = perks.FirstOrDefault(p => p.Id == itemCode);
return new ItemStats
{
ItemCode = itemCode,
Title = perk.Title,
Title = perk?.Title ?? itemCode,
SalesCount = entities.Count(),
Total = total,
TotalFormatted = $"{total.ShowMoney(currencyData.Divisibility)} {settings.TargetCurrency}"