From 9f4419ada0e4cad5cd416d5d13ccc62ef24c4f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9F=D1=83=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD?= Date: Fri, 21 Apr 2023 22:54:02 +0400 Subject: [PATCH] fix --- .../PrecastConcretePlantBusinessLogic/OrderLogic.cs | 9 +++++++++ .../BusinessLogicsContracts/IShopLogic.cs | 2 ++ 2 files changed, 11 insertions(+) diff --git a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs index bc2fc77..25156cf 100644 --- a/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantBusinessLogic/OrderLogic.cs @@ -98,6 +98,15 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic $"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}", nameof(vmodel)); } + if (orderStatus == OrderStatus.Готов) + { + var vreinforced = _reinforcedStorage.GetElement(new() { Id = vmodel.ReinforcedId }); + + if (vreinforced == null || !_shopLogic.AddReinforcedsInShops(vreinforced, vmodel.Count)) + { + throw new Exception($"Не удалось заполнить магазины изделием '{vreinforced?.ReinforcedName ?? string.Empty}' из заказа {vmodel.Id}"); + } + } model.Status = orderStatus; model.ReinforcedId = vmodel.ReinforcedId; model.Sum = vmodel.Sum; diff --git a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IShopLogic.cs b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IShopLogic.cs index 6460d8b..cee1038 100644 --- a/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IShopLogic.cs +++ b/PrecastConcretePlant/PrecastConcretePlantContracts/BusinessLogicsContracts/IShopLogic.cs @@ -13,5 +13,7 @@ namespace PrecastConcretePlantContracts.BusinessLogicsContracts bool Update(ShopBindingModel model); bool Delete(ShopBindingModel model); bool AddReinforced(ShopSearchModel model, IReinforcedModel reinforced, int count); + bool AddReinforcedsInShops(IReinforcedModel reinforceds, int count); + public bool SellReinforceds(IReinforcedModel reinforceds, int needCount); } }