From 705177bf7c797a19c071cec3cb5e135fb5447e63 Mon Sep 17 00:00:00 2001 From: Thomas Ryan Date: Wed, 6 Nov 2024 13:22:54 -0800 Subject: [PATCH] Worked on #475. --- NumberSearch.Ingest/Owned.cs | 5 +---- NumberSearch.Ops/Models/Cart.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/NumberSearch.Ingest/Owned.cs b/NumberSearch.Ingest/Owned.cs index 61acb678..26b49c1d 100644 --- a/NumberSearch.Ingest/Owned.cs +++ b/NumberSearch.Ingest/Owned.cs @@ -1,5 +1,4 @@ -using FirstCom; -using FirstCom.Models; +using FirstCom.Models; using Flurl.Http; @@ -11,8 +10,6 @@ using Serilog; -using ServiceReference; - using System; using System.Collections.Generic; using System.Linq; diff --git a/NumberSearch.Ops/Models/Cart.cs b/NumberSearch.Ops/Models/Cart.cs index 458cbb27..3ace5e20 100644 --- a/NumberSearch.Ops/Models/Cart.cs +++ b/NumberSearch.Ops/Models/Cart.cs @@ -476,7 +476,16 @@ public Dictionary ProductOrdersToDictionary() if (!string.IsNullOrWhiteSpace(foreignId)) { - dict.Add(foreignId, item); + var checkDuplicate = dict.TryGetValue(foreignId, out var value); + if (checkDuplicate && value is not null) + { + // Merge the quantities. + value.Quantity += item.Quantity; + } + else + { + dict.Add(foreignId, item); + } } }