From 9e6dab9f5f1fbd21673eea76adebac4fb34e709b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B0=D0=B1=D0=B5=D0=B5=D0=B2=20=D0=90=D0=BB=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Sun, 21 Apr 2024 16:10:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=81=D0=BB=D0=BE=D1=8F=20=D0=B1=D0=B8=D0=B7=D0=BD?= =?UTF-8?q?=D0=B5=D1=81=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccountingWarehouseProducts.sln | 6 + ...ntingWarehouseProductsBusinessLogic.csproj | 13 ++ .../BusinessLogic/OrderLogic.cs | 136 ++++++++++++++++++ .../BusinessLogic/ProductLogic.cs | 93 ++++++++++++ .../BusinessLogic/ShipmentLogic.cs | 89 ++++++++++++ .../BusinessLogic/StandLogic.cs | 89 ++++++++++++ .../BusinessLogic/SupplierLogic.cs | 93 ++++++++++++ .../BusinessLogic/WarehouseLogic.cs | 93 ++++++++++++ 8 files changed, 612 insertions(+) create mode 100644 AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/AccountingWarehouseProductsBusinessLogic.csproj create mode 100644 AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/OrderLogic.cs create mode 100644 AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/ProductLogic.cs create mode 100644 AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/ShipmentLogic.cs create mode 100644 AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/StandLogic.cs create mode 100644 AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/SupplierLogic.cs create mode 100644 AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/WarehouseLogic.cs diff --git a/AccountingWarehouseProducts/AccountingWarehouseProducts.sln b/AccountingWarehouseProducts/AccountingWarehouseProducts.sln index e49f4b8..cfb45cd 100644 --- a/AccountingWarehouseProducts/AccountingWarehouseProducts.sln +++ b/AccountingWarehouseProducts/AccountingWarehouseProducts.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountingWarehouseProducts EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountingWarehouseProductsContracts", "AccountingWarehouseProductsContracts\AccountingWarehouseProductsContracts.csproj", "{4633456D-A979-41D6-9D0A-A6DAA6A17766}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountingWarehouseProductsBusinessLogic", "AccountingWarehouseProductsBusinessLogic\AccountingWarehouseProductsBusinessLogic.csproj", "{7F90D2FA-8F89-4200-92FC-CFFF489AD6C9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {4633456D-A979-41D6-9D0A-A6DAA6A17766}.Debug|Any CPU.Build.0 = Debug|Any CPU {4633456D-A979-41D6-9D0A-A6DAA6A17766}.Release|Any CPU.ActiveCfg = Release|Any CPU {4633456D-A979-41D6-9D0A-A6DAA6A17766}.Release|Any CPU.Build.0 = Release|Any CPU + {7F90D2FA-8F89-4200-92FC-CFFF489AD6C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F90D2FA-8F89-4200-92FC-CFFF489AD6C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F90D2FA-8F89-4200-92FC-CFFF489AD6C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F90D2FA-8F89-4200-92FC-CFFF489AD6C9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/AccountingWarehouseProductsBusinessLogic.csproj b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/AccountingWarehouseProductsBusinessLogic.csproj new file mode 100644 index 0000000..a936981 --- /dev/null +++ b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/AccountingWarehouseProductsBusinessLogic.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/OrderLogic.cs b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/OrderLogic.cs new file mode 100644 index 0000000..366d6e5 --- /dev/null +++ b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/OrderLogic.cs @@ -0,0 +1,136 @@ +using AccountingWarehouseProductsContracts.BindingModels; +using AccountingWarehouseProductsContracts.BusinessLogicsContracts; +using AccountingWarehouseProductsContracts.SearchModels; +using AccountingWarehouseProductsContracts.StoragesContracts; +using AccountingWarehouseProductsContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AccountingWarehouseProductsBusinessLogic.BusinessLogic +{ + public class OrderLogic : IOrderLogic + { + private readonly IOrderStorage _orderStorage; + + public OrderLogic(IOrderStorage orderStorage) + { + _orderStorage = orderStorage; + } + + public OrderViewModel? ReadElement(OrderSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + var element = _orderStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(OrderSearchModel? model) + { + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Create(OrderBindingModel model) + { + CheckModel(model); + if (_orderStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(OrderBindingModel model) + { + CheckModel(model, false); + if (_orderStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public bool Update(OrderBindingModel model) + { + CheckModel(model); + if (_orderStorage.Update(model) == null) + { + return false; + } + return true; + } + + public bool OrderedOrder(OrderBindingModel model) + { + return StatusUpdate(model, AccountingWarehouseProductsDataModels.Enums.OrderStatus.Заказан); + } + + public bool ComeOrder(OrderBindingModel model) + { + return StatusUpdate(model, AccountingWarehouseProductsDataModels.Enums.OrderStatus.Пришёл); + } + + public bool TakeOrder(OrderBindingModel model) + { + return StatusUpdate(model, AccountingWarehouseProductsDataModels.Enums.OrderStatus.Принят); + } + + public bool ArrangeOrder(OrderBindingModel model) + { + return StatusUpdate(model, AccountingWarehouseProductsDataModels.Enums.OrderStatus.Расстановлен); + } + + public bool ChekOrder(OrderBindingModel model) + { + return StatusUpdate(model, AccountingWarehouseProductsDataModels.Enums.OrderStatus.Проверен); + } + + public bool DeliverOrder(OrderBindingModel model) + { + return StatusUpdate(model, AccountingWarehouseProductsDataModels.Enums.OrderStatus.Доставлен); + } + + private bool StatusUpdate(OrderBindingModel model, AccountingWarehouseProductsDataModels.Enums.OrderStatus newStatus) + { + + if (model.Status + 1 != newStatus) + { + return false; + } + model.Status = newStatus; + if (_orderStorage.Update(model) == null) + { + model.Status--; + return false; + } + return true; + } + + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + } + } +} diff --git a/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/ProductLogic.cs b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/ProductLogic.cs new file mode 100644 index 0000000..07a4bad --- /dev/null +++ b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/ProductLogic.cs @@ -0,0 +1,93 @@ +using AccountingWarehouseProductsContracts.BindingModels; +using AccountingWarehouseProductsContracts.BusinessLogicsContracts; +using AccountingWarehouseProductsContracts.SearchModels; +using AccountingWarehouseProductsContracts.StoragesContracts; +using AccountingWarehouseProductsContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AccountingWarehouseProductsBusinessLogic.BusinessLogic +{ + public class ProductLogic : IProductLogic + { + private readonly IProductStorage _productStorage; + + public ProductLogic(IProductStorage buyerStorage) + { + _productStorage = buyerStorage; + } + public ProductViewModel? ReadElement(ProductSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + var element = _productStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(ProductSearchModel? model) + { + var list = model == null ? _productStorage.GetFullList() : _productStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Create(ProductBindingModel model) + { + CheckModel(model); + if (_productStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(ProductBindingModel model) + { + CheckModel(model, false); + if (_productStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public bool Update(ProductBindingModel model) + { + CheckModel(model); + if (_productStorage.Update(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(ProductBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ProductName)) + { + throw new ArgumentNullException("Нет названия", nameof(model.ProductName)); + } + } + } +} diff --git a/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/ShipmentLogic.cs b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/ShipmentLogic.cs new file mode 100644 index 0000000..2721b66 --- /dev/null +++ b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/ShipmentLogic.cs @@ -0,0 +1,89 @@ +using AccountingWarehouseProductsContracts.BindingModels; +using AccountingWarehouseProductsContracts.BusinessLogicsContracts; +using AccountingWarehouseProductsContracts.SearchModels; +using AccountingWarehouseProductsContracts.StoragesContracts; +using AccountingWarehouseProductsContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AccountingWarehouseProductsBusinessLogic.BusinessLogic +{ + public class ShipmentLogic : IShipmentLogic + { + private readonly IShipmentStorage _shipmentStorage; + + public ShipmentLogic(IShipmentStorage shipmentStorage) + { + _shipmentStorage = shipmentStorage; + } + public ShipmentViewModel? ReadElement(ShipmentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + var element = _shipmentStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(ShipmentSearchModel? model) + { + var list = model == null ? _shipmentStorage.GetFullList() : _shipmentStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Create(ShipmentBindingModel model) + { + CheckModel(model); + if (_shipmentStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(ShipmentBindingModel model) + { + CheckModel(model, false); + if (_shipmentStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public bool Update(ShipmentBindingModel model) + { + CheckModel(model); + if (_shipmentStorage.Update(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(ShipmentBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + } + } +} diff --git a/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/StandLogic.cs b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/StandLogic.cs new file mode 100644 index 0000000..b2c9ba3 --- /dev/null +++ b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/StandLogic.cs @@ -0,0 +1,89 @@ +using AccountingWarehouseProductsContracts.BindingModels; +using AccountingWarehouseProductsContracts.BusinessLogicsContracts; +using AccountingWarehouseProductsContracts.SearchModels; +using AccountingWarehouseProductsContracts.StoragesContracts; +using AccountingWarehouseProductsContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AccountingWarehouseProductsBusinessLogic.BusinessLogic +{ + public class StandLogic : IStandLogic + { + private readonly IStandStorage _standStorage; + + public StandLogic(IStandStorage standStorage) + { + _standStorage = standStorage; + } + public StandViewModel? ReadElement(StandSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + var element = _standStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(StandSearchModel? model) + { + var list = model == null ? _standStorage.GetFullList() : _standStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Create(StandBindingModel model) + { + CheckModel(model); + if (_standStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(StandBindingModel model) + { + CheckModel(model, false); + if (_standStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public bool Update(StandBindingModel model) + { + CheckModel(model); + if (_standStorage.Update(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(StandBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + } + } +} diff --git a/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/SupplierLogic.cs b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/SupplierLogic.cs new file mode 100644 index 0000000..8225e21 --- /dev/null +++ b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/SupplierLogic.cs @@ -0,0 +1,93 @@ +using AccountingWarehouseProductsContracts.BindingModels; +using AccountingWarehouseProductsContracts.BusinessLogicsContracts; +using AccountingWarehouseProductsContracts.SearchModels; +using AccountingWarehouseProductsContracts.StoragesContracts; +using AccountingWarehouseProductsContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AccountingWarehouseProductsBusinessLogic.BusinessLogic +{ + public class SupplierLogic : ISupplierLogic + { + private readonly ISupplierStorage _supplierStorage; + + public SupplierLogic(ISupplierStorage supplierStorage) + { + _supplierStorage = supplierStorage; + } + public SupplierViewModel? ReadElement(SupplierSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + var element = _supplierStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(SupplierSearchModel? model) + { + var list = model == null ? _supplierStorage.GetFullList() : _supplierStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Create(SupplierBindingModel model) + { + CheckModel(model); + if (_supplierStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(SupplierBindingModel model) + { + CheckModel(model, false); + if (_supplierStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public bool Update(SupplierBindingModel model) + { + CheckModel(model); + if (_supplierStorage.Update(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(SupplierBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.SupplierName)) + { + throw new ArgumentNullException("Нет названия", nameof(model.SupplierName)); + } + } + } +} diff --git a/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/WarehouseLogic.cs b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/WarehouseLogic.cs new file mode 100644 index 0000000..90c987f --- /dev/null +++ b/AccountingWarehouseProducts/AccountingWarehouseProductsBusinessLogic/BusinessLogic/WarehouseLogic.cs @@ -0,0 +1,93 @@ +using AccountingWarehouseProductsContracts.BindingModels; +using AccountingWarehouseProductsContracts.BusinessLogicsContracts; +using AccountingWarehouseProductsContracts.SearchModels; +using AccountingWarehouseProductsContracts.StoragesContracts; +using AccountingWarehouseProductsContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AccountingWarehouseProductsBusinessLogic.BusinessLogic +{ + public class WarehouseLogic : IWarehouseLogic + { + private readonly IWarehouseStorage _warehouseStorage; + + public WarehouseLogic(IWarehouseStorage warehouseStorage) + { + _warehouseStorage = warehouseStorage; + } + public WarehouseViewModel? ReadElement(WarehouseSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + var element = _warehouseStorage.GetElement(model); + if (element == null) + { + return null; + } + return element; + } + + public List? ReadList(WarehouseSearchModel? model) + { + var list = model == null ? _warehouseStorage.GetFullList() : _warehouseStorage.GetFilteredList(model); + if (list == null) + { + return null; + } + return list; + } + + public bool Create(WarehouseBindingModel model) + { + CheckModel(model); + if (_warehouseStorage.Insert(model) == null) + { + return false; + } + return true; + } + + public bool Delete(WarehouseBindingModel model) + { + CheckModel(model, false); + if (_warehouseStorage.Delete(model) == null) + { + return false; + } + return true; + } + + public bool Update(WarehouseBindingModel model) + { + CheckModel(model); + if (_warehouseStorage.Update(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(WarehouseBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.WarehouseName)) + { + throw new ArgumentNullException("Нет названия", nameof(model.WarehouseName)); + } + } + } +}