From 53bb9dce4765fca860fa7effd683197725ff641a Mon Sep 17 00:00:00 2001 From: goldfest Date: Fri, 5 Apr 2024 00:04:34 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TravelCompanyBusinessLogic/BusinessLogic/ShopLogic.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/ShopLogic.cs b/TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/ShopLogic.cs index 1021630..56cfe73 100644 --- a/TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/ShopLogic.cs +++ b/TravelCompany/TravelCompanyBusinessLogic/BusinessLogic/ShopLogic.cs @@ -123,6 +123,10 @@ namespace TravelCompanyBusinessLogic.BusinessLogics { throw new ArgumentException($"Поставка: Товар с id:{model.TravelId} не найденн"); } + if (shop.ShopTravels.Sum(kv => kv.Value.Item2) + model.Count > shop.TravelMaxCount) + { + throw new ArgumentException("Превышена максимальная вместимость магазина"); + } shop.ShopTravels.Add(model.TravelId, (Travel, model.Count)); } @@ -139,6 +143,7 @@ namespace TravelCompanyBusinessLogic.BusinessLogics return true; } + private void CheckModel(ShopBindingModel model, bool withParams = true) { if (model == null)