Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

GiftVoucherExtensions to use null coalescing operator for customAttributes initialization

KrzysztofPajak25a8c87fcb95
diff --git a/src/Core/Grand.Domain/Orders/GiftVoucherExtensions.cs b/src/Core/Grand.Domain/Orders/GiftVoucherExtensions.cs
index 20c07d24b..e7cd4ec9c 100644
--- a/src/Core/Grand.Domain/Orders/GiftVoucherExtensions.cs
+++ b/src/Core/Grand.Domain/Orders/GiftVoucherExtensions.cs
@@ -23,8 +23,7 @@ public static class GiftVoucherExtensions
string recipientName,
string recipientEmail, string senderName, string senderEmail, string giftVoucherMessage)
{
- if (customAttributes == null)
- customAttributes = new List<CustomAttribute>();
+ customAttributes ??= new List<CustomAttribute>();
customAttributes.Add(new CustomAttribute { Key = "RecipientName", Value = recipientName });
customAttributes.Add(new CustomAttribute { Key = "RecipientEmail", Value = recipientEmail });
@@ -48,8 +47,7 @@ public static class GiftVoucherExtensions
out string recipientEmail, out string senderName,
out string senderEmail, out string giftVoucherMessage)
{
- if (customAttributes == null)
- customAttributes = new List<CustomAttribute>();
+ customAttributes ??= new List<CustomAttribute>();
recipientName = customAttributes.FirstOrDefault(x => x.Key == "RecipientName")?.Value;
recipientEmail = customAttributes.FirstOrDefault(x => x.Key == "RecipientEmail")?.Value;