diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/StoreLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/StoreLogic.cs
index cdea605..bc06417 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/StoreLogic.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/StoreLogic.cs
@@ -6,6 +6,7 @@ using BlacksmithWorkshopContracts.StoragesContracts;
using BlacksmithWorkshopContracts.ViewModels;
using BlacksmithWorkshopDataModels.Models;
using Microsoft.Extensions.Logging;
+using System.Security.Cryptography.X509Certificates;
namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
{
@@ -109,6 +110,12 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
_logger.LogWarning("Store with id {Id} not found", model.Id);
return false;
}
+ var placeLeft = _storeStorage.GetPlaceLeft(selectedStore);
+ if (placeLeft < count)
+ {
+ _logger.LogWarning("Store with id {Id} can't accomodate {Count} items", model.Id, count);
+ return false;
+ }
//ищем изделие в магазине
if (selectedStore.Manufactures.TryGetValue(manufacture.Id, out var manufactureInStore))
{
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IStoreStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IStoreStorage.cs
index d8502eb..503d958 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IStoreStorage.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/StoragesContracts/IStoreStorage.cs
@@ -27,5 +27,6 @@ namespace BlacksmithWorkshopContracts.StoragesContracts
/// Количество
///
bool SellManufacture(IManufactureModel manufacture, int count);
+ int GetPlaceLeft(IStoreModel store);
}
}
\ No newline at end of file
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/StoreStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/StoreStorage.cs
index 192f3ac..4d8b744 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/StoreStorage.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Implements/StoreStorage.cs
@@ -113,5 +113,14 @@ namespace BlacksmithWorkshopFileImplement.Implements
}
return true;
}
+ public int GetPlaceLeft(IStoreModel model)
+ {
+ var store = source.Stores.FirstOrDefault(x => x.Id == model.Id);
+ if (store == null)
+ {
+ return 0;
+ }
+ return store.MaxManufactures - store.Manufactures.Select(x => x.Value.Item2).Sum();
+ }
}
}
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Store.cs b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Store.cs
index 4399b77..265d7d1 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Store.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopFileImplement/Models/Store.cs
@@ -76,7 +76,6 @@ namespace BlacksmithWorkshopFileImplement.Models
OpeningDate= model.OpeningDate;
SavedManufactures = model.Manufactures.ToDictionary(x => x.Value.Item1.Id, x => x.Value.Item2);
_manufactures = null;
- MaxManufactures = model.MaxManufactures;
}
public StoreViewModel GetViewModel => new()
{
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/StoreStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/StoreStorage.cs
index 1fd4c2e..078650a 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/StoreStorage.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopListImplement/Implements/StoreStorage.cs
@@ -108,5 +108,10 @@ namespace BlacksmithWorkshopListImplement.Implements
{
throw new NotImplementedException("Не применяется в данной реализации");
}
+
+ public int GetPlaceLeft(IStoreModel store)
+ {
+ throw new NotImplementedException("Не применяется в данной реализации");
+ }
}
}
\ No newline at end of file