From 731cc522d87448196cba970293dddac16ac3fe97 Mon Sep 17 00:00:00 2001 From: "yuliya.mavrina@internet.ru" Date: Mon, 3 Jun 2024 09:53:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=5F2=D1=81=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RenovationWorkFileImplement/Implements/ShopStorage.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/RenovationWork/RenovationWorkFileImplement/Implements/ShopStorage.cs b/RenovationWork/RenovationWorkFileImplement/Implements/ShopStorage.cs index 5df01af..90385e8 100644 --- a/RenovationWork/RenovationWorkFileImplement/Implements/ShopStorage.cs +++ b/RenovationWork/RenovationWorkFileImplement/Implements/ShopStorage.cs @@ -85,12 +85,14 @@ namespace RenovationWorkFileImplement.Implements } return null; } + private bool CheckSell(int RepairId, int count) { - count -= _source.Shops.Select(x => x.ShopRepairs.Select(y => - (y.Value.Item1.Id == RepairId ? y.Value.Item2 : 0)).Sum()).Sum(); - return count <= 0; + int availableCount = _source.Shops.Sum(x => x.ShopRepairs + .Where(y => y.Value.Item1.Id == RepairId).Sum(y => y.Value.Item2)); + return count <= availableCount; } + public bool SellRepairs(IRepairModel model, int count) { var neededRepair = _source.Repairs.FirstOrDefault(x => x.Id == model.Id);