From ddd14fe06474614f7d66da6434a866410c3166c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Mon, 20 Feb 2023 20:37:47 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D1=80=D0=B5=D1=84=D0=B0=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B5=D0=BD=D0=BE=20=D0=BF=D0=BE=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B0=D0=B3=D0=B0?= =?UTF-8?q?=D0=B7=D0=B8=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfectionaryBusinessLogic/ShopLogic.cs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/ConfectionaryBusinessLogic/ShopLogic.cs b/ConfectionaryBusinessLogic/ShopLogic.cs index 36d618a..b6fb992 100644 --- a/ConfectionaryBusinessLogic/ShopLogic.cs +++ b/ConfectionaryBusinessLogic/ShopLogic.cs @@ -133,21 +133,13 @@ namespace ConfectioneryBusinessLogic } _logger.LogInformation("AddPastryInShop find. Id:{Id}", element.Id); - - if (element.Pastries.TryGetValue(pastry.Id, out var pair)) - { - element.Pastries[pastry.Id] = (pastry, count + pair.Item2); - _logger.LogInformation( - "AddPastryInShop. Has been added {count} {pastry} in {ShopName}", + + var prevCount = element.Pastries.GetValueOrDefault(pastry.Id, (pastry, 0)).Item2; + element.Pastries[pastry.Id] = (pastry, prevCount + count); + _logger.LogInformation( + "AddPastryInShop. Has been added {count} {pastry} in {ShopName}", count, pastry.PastryName, element.Name); - } - else - { - element.Pastries[pastry.Id] = (pastry, count); - _logger.LogInformation( - "AddPastryInShop. Has been added {count} new Pastry {pastry} in {ShopName}", - count, pastry.PastryName, element.Name); - } + _shopStorage.Update(new() { Id = element.Id,