From 39bf5685390412c1c2cb42cfae2772c8f63015d0 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: Sat, 18 Feb 2023 19:15:28 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=B4=D0=B5=D0=BB=D0=B8=D0=B9?= =?UTF-8?q?=20=D0=B2=20=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7=D0=B8=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfectionaryBusinessLogic/ShopLogic.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ConfectionaryBusinessLogic/ShopLogic.cs b/ConfectionaryBusinessLogic/ShopLogic.cs index 5956da2..bf255f6 100644 --- a/ConfectionaryBusinessLogic/ShopLogic.cs +++ b/ConfectionaryBusinessLogic/ShopLogic.cs @@ -181,16 +181,25 @@ namespace ConfectioneryBusinessLogic public bool AddPastriesInShops(IPastryModel pastry, int count) { + if (count <= 0) + { + _logger.LogWarning("AddPastriesInShops. Количество добавляемых изделий должно быть больше 0. Количество - {count}", count); + return false; + } var freePlaces = GetFreePlacesWithPastriesInShops(count); if (freePlaces < 0) { _logger.LogInformation("AddPastriesInShops. Не удалось добавить изделия в магазины, поскольку они переполнены." + - $"Освободите магазины на {-freePlaces} изделий"); + "Освободите магазины на {places} изделий", -freePlaces); return false; } foreach (var shop in _shopStorage.GetFullList()) { var cnt = Math.Min(count, shop.MaxCountPastries - shop.Pastries.Select(x => x.Value.Item2).Sum()); + if (cnt <= 0) + { + continue; + } if (!AddPastry(new() { Id = shop.Id }, pastry, cnt)) { _logger.LogWarning("При добавления изделий во все магазины произошла ошибка");