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; } } }