From 2c54d51c2c51863d4e7093284ef0d81a15dfb0a6 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 12 Feb 2023 23:21:00 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssemblyBusinessLogic/ShopLogic.cs | 12 ++++++++++++ .../BusinessLogicsContarcts/IShopLogic.cs | 1 + .../StoragesContracts/IShopStorage.cs | 7 ++----- .../Implements/ShopStorage.cs | 13 +++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ShopLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ShopLogic.cs index edc3886..544b405 100644 --- a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ShopLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/ShopLogic.cs @@ -114,5 +114,17 @@ namespace FurnitureAssemblyBusinessLogic throw new InvalidOperationException("Магазин с таким названием уже есть"); } } + + public bool AddFurniture(ShopBindingModel model, FurnitureBindingModel furnitureModel, int count) + { + CheckModel(model); + + if (_shopStorage.AddFurniture(model, furnitureModel, count) == null) + { + _logger.LogWarning("Replenishment operation failed"); + return false; + } + return true; + } } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IShopLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IShopLogic.cs index 1660abe..d08b39d 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IShopLogic.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContarcts/IShopLogic.cs @@ -16,5 +16,6 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContarcts bool Create(ShopBindingModel model); bool Update(ShopBindingModel model); bool Delete(ShopBindingModel model); + bool AddFurniture(ShopBindingModel model, FurnitureBindingModel furnitureModel, int count); } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IShopStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IShopStorage.cs index 43a0aaa..a72939f 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IShopStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IShopStorage.cs @@ -1,11 +1,7 @@ using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.SearchModels; using FurnitureAssemblyContracts.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + namespace FurnitureAssemblyContracts.StoragesContracts { @@ -17,5 +13,6 @@ namespace FurnitureAssemblyContracts.StoragesContracts ShopViewModel? Insert(ShopBindingModel model); ShopViewModel? Update(ShopBindingModel model); ShopViewModel? Delete(ShopBindingModel model); + ShopViewModel? AddFurniture(ShopBindingModel model, FurnitureBindingModel furniture, int count); } } diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ShopStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ShopStorage.cs index 65e0e2b..3b1731a 100644 --- a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ShopStorage.cs +++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ShopStorage.cs @@ -109,5 +109,18 @@ namespace FurnitureAssemblyListImplement.Implements } return null; } + + public ShopViewModel? AddFurniture(ShopBindingModel model, FurnitureBindingModel furniture, int count) + { + foreach (var shop in _source.Shops) + { + if (shop.Id == model.Id) + { + shop.AddFurniture(model, furniture, count); + return shop.GetViewModel; + } + } + return null; + } } }