From cc59bf5dd512df1000a0b430fe2f755e9ff73fb4 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 23 Mar 2023 22:25:19 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D1=83=D1=87=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/ShopLogic.cs | 20 +++++++++---------- .../BindingModels/ShopBindingModel.cs | 2 +- .../ViewModels/ShopViewModel.cs | 2 +- .../Models/IShopModel.cs | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ShopLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ShopLogic.cs index acb9128..5f7cedb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ShopLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ShopLogic.cs @@ -86,13 +86,13 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic return false; } - if (!shop.Manufactures.ContainsKey(manufacture.Id)) + if (!shop.ShopManufactures.ContainsKey(manufacture.Id)) { - shop.Manufactures[manufacture.Id] = (manufacture, count); + shop.ShopManufactures[manufacture.Id] = (manufacture, count); } else { - shop.Manufactures[manufacture.Id] = (manufacture, shop.Manufactures[manufacture.Id].Item2 + count); + shop.ShopManufactures[manufacture.Id] = (manufacture, shop.ShopManufactures[manufacture.Id].Item2 + count); } _shopStorage.Update(new ShopBindingModel() @@ -101,7 +101,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic Address = shop.Address, DateOpen = shop.DateOpen, MaxCountManufactures = shop.MaxCountManufactures, - Manufactures = shop.Manufactures + ShopManufactures = shop.ShopManufactures }); return true; @@ -112,9 +112,9 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic { int _countManufactures = 0; - foreach (var manufacture in model.Manufactures) + foreach (var manufacture in model.ShopManufactures) { - _countManufactures += model.Manufactures[manufacture.Key].Item2; + _countManufactures += model.ShopManufactures[manufacture.Key].Item2; } if(_countManufactures + count > model.MaxCountManufactures) @@ -211,7 +211,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic _logger.LogInformation("AddManufactures. Manufacture: {Manufacture}. Count: {Count}", model?.ManufactureName, count); - var capacity = _shopStorage.GetFullList().Select(x => x.MaxCountManufactures - x.Manufactures.Select(x => x.Value.Item2).Sum()).Sum() - count; + var capacity = _shopStorage.GetFullList().Select(x => x.MaxCountManufactures - x.ShopManufactures.Select(x => x.Value.Item2).Sum()).Sum() - count; if (capacity < 0) { @@ -221,16 +221,16 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic foreach (var shop in _shopStorage.GetFullList()) { - if (shop.MaxCountManufactures - shop.Manufactures.Select(x => x.Value.Item2).Sum() < count) + if (shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum() < count) { - if (!AddManufacture(new() { Id = shop.Id }, model, shop.MaxCountManufactures - shop.Manufactures.Select(x => x.Value.Item2).Sum())) + if (!AddManufacture(new() { Id = shop.Id }, model, shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum())) { _logger.LogWarning("AddManufactures operation failed."); return false; } - count -= shop.MaxCountManufactures - shop.Manufactures.Select(x => x.Value.Item2).Sum(); + count -= shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum(); } else { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ShopBindingModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ShopBindingModel.cs index 0afcf18..cdaaa0a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ShopBindingModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BindingModels/ShopBindingModel.cs @@ -15,7 +15,7 @@ namespace BlacksmithWorkshopContracts.BindingModels public DateTime DateOpen { get; set; } = DateTime.Now; - public Dictionary Manufactures { get; set; } = new(); + public Dictionary ShopManufactures { get; set; } = new(); public int Id { get; set; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ShopViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ShopViewModel.cs index 9604850..67d9e18 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ShopViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ShopViewModel.cs @@ -21,7 +21,7 @@ namespace BlacksmithWorkshopContracts.ViewModels [DisplayName("Дата открытия")] public DateTime DateOpen { get; set; } = DateTime.Now; - public Dictionary Manufactures { get; set; } = new(); + public Dictionary ShopManufactures { get; set; } = new(); [DisplayName("Вместимость магазина")] public int MaxCountManufactures { get; set; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IShopModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IShopModel.cs index 46e4d68..3b50f3a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IShopModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDataModels/Models/IShopModel.cs @@ -23,6 +23,6 @@ namespace BlacksmithWorkshopDataModels.Models int MaxCountManufactures { get; } //изделия в магазине - Dictionary Manufactures { get; } + Dictionary ShopManufactures { get; } } }