From 0e7abff08d9f8d8a87296312544ecdaa7cda087d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=B0=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A4=D0=B5=D0=B4?= =?UTF-8?q?=D0=BE=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 22 May 2024 11:39:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=83=20=D0=BF=D1=83=20=D0=BF=D1=83=20?= =?UTF-8?q?=D0=BF=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CarpentryWorkshop/CarpentryWorkshop/FormShop.cs | 2 +- .../Implements/ShopStorage.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CarpentryWorkshop/CarpentryWorkshop/FormShop.cs b/CarpentryWorkshop/CarpentryWorkshop/FormShop.cs index 0de17b6..745c9c9 100644 --- a/CarpentryWorkshop/CarpentryWorkshop/FormShop.cs +++ b/CarpentryWorkshop/CarpentryWorkshop/FormShop.cs @@ -63,7 +63,7 @@ namespace CarpentryWorkshopView DataGridView.Rows.Clear(); foreach (var wood in _shopWoods) { - DataGridView.Rows.Add(new object[] { wood.Key, wood.Value.Item1.WoodName, wood.Value.Item2 }); + DataGridView.Rows.Add(new object[] { wood.Key, wood.Value.Item1.WoodName, wood.Value.Item1.Price,wood.Value.Item2 }); } } } diff --git a/CarpentryWorkshop/CarpentryWorkshopFileImplement/Implements/ShopStorage.cs b/CarpentryWorkshop/CarpentryWorkshopFileImplement/Implements/ShopStorage.cs index 6733450..67b3161 100644 --- a/CarpentryWorkshop/CarpentryWorkshopFileImplement/Implements/ShopStorage.cs +++ b/CarpentryWorkshop/CarpentryWorkshopFileImplement/Implements/ShopStorage.cs @@ -79,7 +79,11 @@ namespace CarpentryWorkshopFileImplement.Implements public bool CheckAvailability(int woodId, int count) { - int minus = source.Shops.Select(x => x.ShopWoods.Select(y => (y.Value.Item1.Id == woodId ? y.Value.Item2 : 0)).Sum()).Sum(); + int minus = source.Shops + .SelectMany(shop => shop.ShopWoods + .Where(wood => wood.Value.Item1.Id == woodId) + .Select(wood => wood.Value.Item2)) + .Sum(); count -= minus; return count <= 0; }