From 749d98cd26a55088718b83bb94bc967b95ef021d Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Tue, 5 Mar 2024 13:09:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=A3=D0=96=D0=9D=D0=9E=20=D0=91=D0=9E?= =?UTF-8?q?=D0=9B=D0=AC=D0=A8=D0=95=20=D0=9B=D0=98=D0=9D=D0=9A=20=D0=97?= =?UTF-8?q?=D0=90=D0=9F=D0=A0=D0=9E=D0=A1=D0=9E=D0=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/OrderLogic.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/IceCreamShop/IceCreamShopBusinessLogic/BusinessLogic/OrderLogic.cs b/IceCreamShop/IceCreamShopBusinessLogic/BusinessLogic/OrderLogic.cs index 83cd6e2..b1de8d2 100644 --- a/IceCreamShop/IceCreamShopBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/IceCreamShop/IceCreamShopBusinessLogic/BusinessLogic/OrderLogic.cs @@ -67,15 +67,11 @@ namespace IceCreamShopBusinessLogic.BusinessLogic return false; } - int freeSpace = 0; - foreach (var shop in _shopStorage.GetFullList()) - { - freeSpace += shop.MaxCapacity; - foreach (var doc in shop.ShopIceCreams) - { - freeSpace -= doc.Value.Item2; - } - } + int sumCapacity = 0; + int sumCount = 0; + sumCapacity = _shopStorage.GetFullList().Select(x => x.MaxCapacity).Sum(); + sumCount = _shopStorage.GetFullList().Select(x => x.ShopIceCreams.Select(y => y.Value.Item2).Sum()).Sum(); + int freeSpace = sumCapacity - sumCount; if (freeSpace - count < 0) {