From 09978b4cee8ef85fc51651b2a8f1c6c258eae4d5 Mon Sep 17 00:00:00 2001 From: shadowik Date: Thu, 16 Feb 2023 07:52:03 +0300 Subject: [PATCH] Renaming --- .../Models/IProductModel.cs | 15 --- BankExecutor/BankExecutor/FormProduct.resx | 120 ------------------ .../BusinessLogics/ProductLogic.cs | 111 ---------------- .../BindingModels/ProductBindingModel.cs | 13 -- .../BusinessLogicsContracts/IProductLogic.cs | 15 --- .../SearchModels/ProductSearchModel.cs | 8 -- .../StoragesContracts/IProductStorage.cs | 16 --- .../ViewModels/ProductViewModel.cs | 15 --- .../Implements/ProductStorage.cs | 101 --------------- .../Models/Product.cs | 45 ------- .../BankExecutor.sln => Pizzeria/Pizzeria.sln | 10 +- .../Pizzeria}/FormComponent.Designer.cs | 37 +++--- .../Pizzeria}/FormComponent.cs | 16 +-- .../Pizzeria}/FormComponent.resx | 0 .../Pizzeria}/FormComponents.Designer.cs | 93 +++++++------- .../Pizzeria}/FormComponents.cs | 16 +-- .../Pizzeria}/FormComponents.resx | 0 .../Pizzeria}/FormCreateOrder.Designer.cs | 44 +++---- .../Pizzeria}/FormCreateOrder.cs | 44 +++---- .../Pizzeria}/FormCreateOrder.resx | 0 .../Pizzeria}/FormMain.Designer.cs | 90 +++++++------ .../Pizzeria}/FormMain.cs | 20 +-- .../Pizzeria}/FormMain.resx | 0 .../Pizzeria/FormPizza.Designer.cs | 84 ++++++------ .../Pizzeria/FormPizza.cs | 84 ++++++------ .../Pizzeria/FormPizza.resx | 0 .../Pizzeria/FormPizzaComponent.Designer.cs | 45 ++++--- .../Pizzeria/FormPizzaComponent.cs | 14 +- .../Pizzeria/FormPizzaComponent.resx | 0 .../Pizzeria/FormPizzas.Designer.cs | 12 +- .../Pizzeria/FormPizzas.cs | 38 +++--- Pizzeria/Pizzeria/FormPizzas.resx | 60 +++++++++ .../Pizzeria/PizzeriaView.csproj | 9 +- .../Pizzeria}/Program.cs | 24 ++-- .../Pizzeria}/nlog.config | 0 .../BusinessLogics/ComponentLogic.cs | 18 +-- .../BusinessLogics/OrderLogic.cs | 22 ++-- .../BusinessLogics/PizzaLogic.cs | 111 ++++++++++++++++ .../PizzeriaBusinessLogic.csproj | 4 +- .../BindingModels/ComponentBindingModel.cs | 4 +- .../BindingModels/OrderBindingModel.cs | 8 +- .../BindingModels/PizzaBindingModel.cs | 13 ++ .../IComponentLogic.cs | 8 +- .../BusinessLogicsContracts/IOrderLogic.cs | 8 +- .../BusinessLogicsContracts/IPizzaLogic.cs | 15 +++ .../PizzeriaContracts.csproj | 4 +- .../SearchModels/ComponentSearchModel.cs | 2 +- .../SearchModels/OrderSearchModel.cs | 2 +- .../SearchModels/PizzaSearchModel.cs | 8 ++ .../StoragesContracts/IComponentStorage.cs | 8 +- .../StoragesContracts/IOrderStorage.cs | 8 +- .../StoragesContracts/IPizzaStorage.cs | 16 +++ .../ViewModels/ComponentViewModel.cs | 6 +- .../ViewModels/OrderViewModel.cs | 12 +- .../ViewModels/PizzaViewModel.cs | 15 +++ .../PizzeriaDataModels}/Enums/OrderStatus.cs | 2 +- .../PizzeriaDataModels}/IId.cs | 2 +- .../Models/IComponentModel.cs | 2 +- .../PizzeriaDataModels}/Models/IOrderModel.cs | 6 +- .../PizzeriaDataModels/Models/IPizzaModel.cs | 15 +++ .../PizzeriaDataModels.csproj | 0 .../DataListSingleton.cs | 8 +- .../Implements/ComponentStorage.cs | 12 +- .../Implements/OrderStorage.cs | 32 ++--- .../Implements/PizzaStorage.cs | 101 +++++++++++++++ .../Models/Component.cs | 8 +- .../PizzeriaListImplement}/Models/Order.cs | 31 ++--- .../PizzeriaListImplement/Models/Pizza.cs | 45 +++++++ .../PizzeriaListImplement.csproj | 4 +- 69 files changed, 866 insertions(+), 893 deletions(-) delete mode 100644 BankExecutor/AbstractBankDataModels/Models/IProductModel.cs delete mode 100644 BankExecutor/BankExecutor/FormProduct.resx delete mode 100644 BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ProductLogic.cs delete mode 100644 BankExecutor/BankExecutorContracts/BindingModels/ProductBindingModel.cs delete mode 100644 BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IProductLogic.cs delete mode 100644 BankExecutor/BankExecutorContracts/SearchModels/ProductSearchModel.cs delete mode 100644 BankExecutor/BankExecutorContracts/StoragesContracts/IProductStorage.cs delete mode 100644 BankExecutor/BankExecutorContracts/ViewModels/ProductViewModel.cs delete mode 100644 BankExecutor/BankExecutorListImplement/Implements/ProductStorage.cs delete mode 100644 BankExecutor/BankExecutorListImplement/Models/Product.cs rename BankExecutor/BankExecutor.sln => Pizzeria/Pizzeria.sln (72%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormComponent.Designer.cs (80%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormComponent.cs (90%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormComponent.resx (100%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormComponents.Designer.cs (53%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormComponents.cs (90%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormComponents.resx (100%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormCreateOrder.Designer.cs (80%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormCreateOrder.cs (70%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormCreateOrder.resx (100%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormMain.Designer.cs (68%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormMain.cs (91%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/FormMain.resx (100%) rename BankExecutor/BankExecutor/FormProduct.Designer.cs => Pizzeria/Pizzeria/FormPizza.Designer.cs (77%) rename BankExecutor/BankExecutor/FormProduct.cs => Pizzeria/Pizzeria/FormPizza.cs (69%) rename BankExecutor/BankExecutor/FormProductComponent.resx => Pizzeria/Pizzeria/FormPizza.resx (100%) rename BankExecutor/BankExecutor/FormProductComponent.Designer.cs => Pizzeria/Pizzeria/FormPizzaComponent.Designer.cs (77%) rename BankExecutor/BankExecutor/FormProductComponent.cs => Pizzeria/Pizzeria/FormPizzaComponent.cs (84%) rename BankExecutor/BankExecutor/FormProducts.resx => Pizzeria/Pizzeria/FormPizzaComponent.resx (100%) rename BankExecutor/BankExecutor/FormProducts.Designer.cs => Pizzeria/Pizzeria/FormPizzas.Designer.cs (95%) rename BankExecutor/BankExecutor/FormProducts.cs => Pizzeria/Pizzeria/FormPizzas.cs (76%) create mode 100644 Pizzeria/Pizzeria/FormPizzas.resx rename BankExecutor/BankExecutor/BankExecutorView.csproj => Pizzeria/Pizzeria/PizzeriaView.csproj (53%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/Program.cs (74%) rename {BankExecutor/BankExecutor => Pizzeria/Pizzeria}/nlog.config (100%) rename {BankExecutor/BankExecutorBusinessLogic => Pizzeria/PizzeriaBusinessLogic}/BusinessLogics/ComponentLogic.cs (85%) rename {BankExecutor/BankExecutorBusinessLogic => Pizzeria/PizzeriaBusinessLogic}/BusinessLogics/OrderLogic.cs (86%) create mode 100644 Pizzeria/PizzeriaBusinessLogic/BusinessLogics/PizzaLogic.cs rename BankExecutor/BankExecutorBusinessLogic/BankExecutorBusinessLogic.csproj => Pizzeria/PizzeriaBusinessLogic/PizzeriaBusinessLogic.csproj (71%) rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/BindingModels/ComponentBindingModel.cs (71%) rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/BindingModels/OrderBindingModel.cs (69%) create mode 100644 Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/BusinessLogicsContracts/IComponentLogic.cs (65%) rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/BusinessLogicsContracts/IOrderLogic.cs (63%) create mode 100644 Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs rename BankExecutor/BankExecutorContracts/BankExecutorContracts.csproj => Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj (61%) rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/SearchModels/ComponentSearchModel.cs (74%) rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/SearchModels/OrderSearchModel.cs (64%) create mode 100644 Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/StoragesContracts/IComponentStorage.cs (71%) rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/StoragesContracts/IOrderStorage.cs (69%) create mode 100644 Pizzeria/PizzeriaContracts/StoragesContracts/IPizzaStorage.cs rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/ViewModels/ComponentViewModel.cs (65%) rename {BankExecutor/BankExecutorContracts => Pizzeria/PizzeriaContracts}/ViewModels/OrderViewModel.cs (71%) create mode 100644 Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs rename {BankExecutor/AbstractBankDataModels => Pizzeria/PizzeriaDataModels}/Enums/OrderStatus.cs (88%) rename {BankExecutor/AbstractBankDataModels => Pizzeria/PizzeriaDataModels}/IId.cs (84%) rename {BankExecutor/AbstractBankDataModels => Pizzeria/PizzeriaDataModels}/Models/IComponentModel.cs (86%) rename {BankExecutor/AbstractBankDataModels => Pizzeria/PizzeriaDataModels}/Models/IOrderModel.cs (75%) create mode 100644 Pizzeria/PizzeriaDataModels/Models/IPizzaModel.cs rename BankExecutor/AbstractBankDataModels/BankExecutorDataModels.csproj => Pizzeria/PizzeriaDataModels/PizzeriaDataModels.csproj (100%) rename {BankExecutor/BankExecutorListImplement => Pizzeria/PizzeriaListImplement}/DataListSingleton.cs (76%) rename {BankExecutor/BankExecutorListImplement => Pizzeria/PizzeriaListImplement}/Implements/ComponentStorage.cs (92%) rename {BankExecutor/BankExecutorListImplement => Pizzeria/PizzeriaListImplement}/Implements/OrderStorage.cs (75%) create mode 100644 Pizzeria/PizzeriaListImplement/Implements/PizzaStorage.cs rename {BankExecutor/BankExecutorListImplement => Pizzeria/PizzeriaListImplement}/Models/Component.cs (85%) rename {BankExecutor/BankExecutorListImplement => Pizzeria/PizzeriaListImplement}/Models/Order.cs (63%) create mode 100644 Pizzeria/PizzeriaListImplement/Models/Pizza.cs rename BankExecutor/BankExecutorListImplement/BankExecutorListImplement.csproj => Pizzeria/PizzeriaListImplement/PizzeriaListImplement.csproj (56%) diff --git a/BankExecutor/AbstractBankDataModels/Models/IProductModel.cs b/BankExecutor/AbstractBankDataModels/Models/IProductModel.cs deleted file mode 100644 index 25765a5..0000000 --- a/BankExecutor/AbstractBankDataModels/Models/IProductModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BankExecutorDataModels.Models -{ - public interface IProductModel : IId - { - string ProductName { get; } - double Price { get; } - Dictionary ProductComponents { get; } - } -} diff --git a/BankExecutor/BankExecutor/FormProduct.resx b/BankExecutor/BankExecutor/FormProduct.resx deleted file mode 100644 index 1af7de1..0000000 --- a/BankExecutor/BankExecutor/FormProduct.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ProductLogic.cs b/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ProductLogic.cs deleted file mode 100644 index 669638b..0000000 --- a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ProductLogic.cs +++ /dev/null @@ -1,111 +0,0 @@ -using Microsoft.Extensions.Logging; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.BusinessLogicsContracts; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.StoragesContracts; -using BankExecutorContracts.ViewModels; - -namespace BankExecutorBusinessLogic.BusinessLogics -{ - public class ProductLogic : IProductLogic - { - private readonly ILogger _logger; - private readonly IProductStorage _ProductStorage; - public ProductLogic(ILogger logger, IProductStorage ProductStorage) - { - _logger = logger; - _ProductStorage= ProductStorage; - } - public List? ReadList(ProductSearchModel? model) - { - _logger.LogInformation("ReadList. ProductName:{ProductName}.Id:{ Id}", model?.ProductName, model?.Id); - var list = model == null ? _ProductStorage.GetFullList() : _ProductStorage.GetFilteredList(model); - if (list == null) - { - _logger.LogWarning("ReadList return null list"); - return null; - } - _logger.LogInformation("ReadList. Count:{Count}", list.Count); - return list; - } - public ProductViewModel? ReadElement(ProductSearchModel model) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - _logger.LogInformation("ReadElement. ProductName:{ProductName}.Id:{ Id}", model.ProductName, model.Id); - var element = _ProductStorage.GetElement(model); - if (element == null) - { - _logger.LogWarning("ReadElement element not found"); - return null; - } - _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); - return element; - } - public bool Create(ProductBindingModel model) - { - CheckModel(model); - if (_ProductStorage.Insert(model) == null) - { - _logger.LogWarning("Insert operation failed"); - return false; - } - return true; - } - public bool Update(ProductBindingModel model) - { - CheckModel(model); - if (_ProductStorage.Update(model) == null) - { - _logger.LogWarning("Update operation failed"); - return false; - } - return true; - } - public bool Delete(ProductBindingModel model) - { - CheckModel(model, false); - _logger.LogInformation("Delete. Id:{Id}", model.Id); - if (_ProductStorage.Delete(model) == null) - { - _logger.LogWarning("Delete operation failed"); - 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)); - } - if (model.Price <= 0) - { - throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price)); - } - if(model.ProductComponents==null || model.ProductComponents.Count == 0) - { - throw new ArgumentNullException("Перечень компонентов не может быть пустым", nameof(model.ProductComponents)); - } - _logger.LogInformation("Product. ProductName:{ProductName}.Price:{Price}.Id: { Id}", model.ProductName, model.Price, model.Id); - var element = _ProductStorage.GetElement(new ProductSearchModel - { - ProductName = model.ProductName - }); - if (element != null && element.Id != model.Id) - { - throw new InvalidOperationException("Изделие с таким названием уже есть"); - } - } - } -} diff --git a/BankExecutor/BankExecutorContracts/BindingModels/ProductBindingModel.cs b/BankExecutor/BankExecutorContracts/BindingModels/ProductBindingModel.cs deleted file mode 100644 index 07558ef..0000000 --- a/BankExecutor/BankExecutorContracts/BindingModels/ProductBindingModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using BankExecutorDataModels.Models; - -namespace BankExecutorContracts.BindingModels -{ - public class ProductBindingModel : IProductModel - { - public int Id { get; set; } - public string ProductName { get; set; } = string.Empty; - public double Price { get; set; } - public Dictionary ProductComponents { get; set; } = new(); - - } -} diff --git a/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IProductLogic.cs b/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IProductLogic.cs deleted file mode 100644 index 042bf4c..0000000 --- a/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IProductLogic.cs +++ /dev/null @@ -1,15 +0,0 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.ViewModels; - -namespace BankExecutorContracts.BusinessLogicsContracts -{ - public interface IProductLogic - { - List? ReadList(ProductSearchModel? model); - ProductViewModel? ReadElement(ProductSearchModel model); - bool Create(ProductBindingModel model); - bool Update(ProductBindingModel model); - bool Delete(ProductBindingModel model); - } -} diff --git a/BankExecutor/BankExecutorContracts/SearchModels/ProductSearchModel.cs b/BankExecutor/BankExecutorContracts/SearchModels/ProductSearchModel.cs deleted file mode 100644 index 902b09c..0000000 --- a/BankExecutor/BankExecutorContracts/SearchModels/ProductSearchModel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace BankExecutorContracts.SearchModels -{ - public class ProductSearchModel - { - public int? Id { get; set; } - public string? ProductName { get; set; } - } -} diff --git a/BankExecutor/BankExecutorContracts/StoragesContracts/IProductStorage.cs b/BankExecutor/BankExecutorContracts/StoragesContracts/IProductStorage.cs deleted file mode 100644 index bfe3848..0000000 --- a/BankExecutor/BankExecutorContracts/StoragesContracts/IProductStorage.cs +++ /dev/null @@ -1,16 +0,0 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.ViewModels; - -namespace BankExecutorContracts.StoragesContracts -{ - public interface IProductStorage - { - List GetFullList(); - List GetFilteredList(ProductSearchModel model); - ProductViewModel? GetElement(ProductSearchModel model); - ProductViewModel? Insert(ProductBindingModel model); - ProductViewModel? Update(ProductBindingModel model); - ProductViewModel? Delete(ProductBindingModel model); - } -} diff --git a/BankExecutor/BankExecutorContracts/ViewModels/ProductViewModel.cs b/BankExecutor/BankExecutorContracts/ViewModels/ProductViewModel.cs deleted file mode 100644 index 6b82665..0000000 --- a/BankExecutor/BankExecutorContracts/ViewModels/ProductViewModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using BankExecutorDataModels.Models; -using System.ComponentModel; - -namespace BankExecutorContracts.ViewModels -{ - public class ProductViewModel : IProductModel - { - public int Id { get; set; } - [DisplayName("Название изделия")] - public string ProductName { get; set; } = string.Empty; - [DisplayName("Цена")] - public double Price { get; set; } - public Dictionary ProductComponents { get;set;} = new(); - } -} diff --git a/BankExecutor/BankExecutorListImplement/Implements/ProductStorage.cs b/BankExecutor/BankExecutorListImplement/Implements/ProductStorage.cs deleted file mode 100644 index 8377442..0000000 --- a/BankExecutor/BankExecutorListImplement/Implements/ProductStorage.cs +++ /dev/null @@ -1,101 +0,0 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.StoragesContracts; -using BankExecutorContracts.ViewModels; -using BankExecutorListImplement.Models; - -namespace BankExecutorListImplement.Implements -{ - public class ProductStorage : IProductStorage - { - private readonly DataListSingleton _source; - public ProductStorage() - { - _source = DataListSingleton.GetInstance(); - } - public List GetFullList() - { - var result = new List(); - foreach (var products in _source.Products) - { - result.Add(products.GetViewModel); - } - return result; - } - public List GetFilteredList(ProductSearchModel model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.ProductName)) - { - return result; - } - foreach (var products in _source.Products) - { - if (products.ProductName.Contains(model.ProductName)) - { - result.Add(products.GetViewModel); - } - } - return result; - } - public ProductViewModel? GetElement(ProductSearchModel model) - { - if (string.IsNullOrEmpty(model.ProductName) && !model.Id.HasValue) - { - return null; - } - foreach (var products in _source.Products) - { - if ((!string.IsNullOrEmpty(model.ProductName) && products.ProductName == model.ProductName) || - (model.Id.HasValue && products.Id == model.Id)) - { - return products.GetViewModel; - } - } - return null; - } - public ProductViewModel? Insert(ProductBindingModel model) - { - model.Id = 1; - foreach (var products in _source.Products) - { - if (model.Id <= products.Id) - { - model.Id = products.Id + 1; - } - } - var newProducts = Product.Create(model); - if (newProducts == null) - { - return null; - } - _source.Products.Add(newProducts); - return newProducts.GetViewModel; - } - public ProductViewModel? Update(ProductBindingModel model) - { - foreach (var products in _source.Products) - { - if (products.Id == model.Id) - { - products.Update(model); - return products.GetViewModel; - } - } - return null; - } - public ProductViewModel? Delete(ProductBindingModel model) - { - for (int i = 0; i < _source.Products.Count; ++i) - { - if (_source.Products[i].Id == model.Id) - { - var element = _source.Products[i]; - _source.Products.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } - } -} diff --git a/BankExecutor/BankExecutorListImplement/Models/Product.cs b/BankExecutor/BankExecutorListImplement/Models/Product.cs deleted file mode 100644 index fec4fda..0000000 --- a/BankExecutor/BankExecutorListImplement/Models/Product.cs +++ /dev/null @@ -1,45 +0,0 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.ViewModels; -using BankExecutorDataModels.Models; - -namespace BankExecutorListImplement.Models -{ - public class Product : IProductModel - { - public int Id { get; private set; } - public string ProductName { get; private set; } = string.Empty; - public double Price { get; private set; } - public Dictionary ProductComponents { get; private set;} = new Dictionary(); - public static Product? Create(ProductBindingModel? model) - { - if (model == null) - { - return null; - } - return new Product() - { - Id = model.Id, - ProductName = model.ProductName, - Price = model.Price, - ProductComponents = model.ProductComponents, - }; - } - public void Update(ProductBindingModel? model) - { - if (model == null) - { - return; - } - ProductName = model.ProductName; - Price = model.Price; - ProductComponents = model.ProductComponents; - } - public ProductViewModel GetViewModel => new() - { - Id = Id, - ProductName = ProductName, - Price = Price, - ProductComponents = ProductComponents - }; - } -} diff --git a/BankExecutor/BankExecutor.sln b/Pizzeria/Pizzeria.sln similarity index 72% rename from BankExecutor/BankExecutor.sln rename to Pizzeria/Pizzeria.sln index 39e3c64..06ac31f 100644 --- a/BankExecutor/BankExecutor.sln +++ b/Pizzeria/Pizzeria.sln @@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32825.248 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorView", "BankExecutor\BankExecutorView.csproj", "{88CAFAB3-C95B-4118-896A-10794A1C5FBE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaView", "Pizzeria\PizzeriaView.csproj", "{88CAFAB3-C95B-4118-896A-10794A1C5FBE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorDataModels", "AbstractBankDataModels\BankExecutorDataModels.csproj", "{03B275B6-CF13-4B65-973F-059CA2A4709D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaDataModels", "PizzeriaDataModels\PizzeriaDataModels.csproj", "{03B275B6-CF13-4B65-973F-059CA2A4709D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorContracts", "BankExecutorContracts\BankExecutorContracts.csproj", "{1FBD781D-AF16-42DE-AE09-E99B898EA0AE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaContracts", "PizzeriaContracts\PizzeriaContracts.csproj", "{1FBD781D-AF16-42DE-AE09-E99B898EA0AE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorBusinessLogic", "BankExecutorBusinessLogic\BankExecutorBusinessLogic.csproj", "{6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaBusinessLogic", "PizzeriaBusinessLogic\PizzeriaBusinessLogic.csproj", "{6BE706A3-4D91-47E0-855A-8B4AB0DB3EB3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankExecutorListImplement", "BankExecutorListImplement\BankExecutorListImplement.csproj", "{17269B24-6A77-4C45-B3DD-AA444F22D9B8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaListImplement", "PizzeriaListImplement\PizzeriaListImplement.csproj", "{17269B24-6A77-4C45-B3DD-AA444F22D9B8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/BankExecutor/BankExecutor/FormComponent.Designer.cs b/Pizzeria/Pizzeria/FormComponent.Designer.cs similarity index 80% rename from BankExecutor/BankExecutor/FormComponent.Designer.cs rename to Pizzeria/Pizzeria/FormComponent.Designer.cs index 1abb41c..61fe96e 100644 --- a/BankExecutor/BankExecutor/FormComponent.Designer.cs +++ b/Pizzeria/Pizzeria/FormComponent.Designer.cs @@ -1,4 +1,4 @@ -namespace BankExecutorView +namespace PizzeriaView { partial class FormComponent { @@ -39,40 +39,43 @@ // labelName // this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(12, 9); + this.labelName.Location = new System.Drawing.Point(10, 7); this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(80, 20); + this.labelName.Size = new System.Drawing.Size(62, 15); this.labelName.TabIndex = 0; this.labelName.Text = "Название:"; // // textBoxName // - this.textBoxName.Location = new System.Drawing.Point(98, 9); + this.textBoxName.Location = new System.Drawing.Point(86, 7); + this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(366, 27); + this.textBoxName.Size = new System.Drawing.Size(321, 23); this.textBoxName.TabIndex = 1; // // textBoxCost // - this.textBoxCost.Location = new System.Drawing.Point(98, 42); + this.textBoxCost.Location = new System.Drawing.Point(86, 32); + this.textBoxCost.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxCost.Name = "textBoxCost"; - this.textBoxCost.Size = new System.Drawing.Size(133, 27); + this.textBoxCost.Size = new System.Drawing.Size(117, 23); this.textBoxCost.TabIndex = 3; // // labelCost // this.labelCost.AutoSize = true; - this.labelCost.Location = new System.Drawing.Point(12, 42); + this.labelCost.Location = new System.Drawing.Point(10, 32); this.labelCost.Name = "labelCost"; - this.labelCost.Size = new System.Drawing.Size(45, 20); + this.labelCost.Size = new System.Drawing.Size(35, 15); this.labelCost.TabIndex = 2; this.labelCost.Text = "Цена"; // // buttonSave // - this.buttonSave.Location = new System.Drawing.Point(171, 90); + this.buttonSave.Location = new System.Drawing.Point(150, 68); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(130, 40); + this.buttonSave.Size = new System.Drawing.Size(114, 30); this.buttonSave.TabIndex = 4; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; @@ -80,9 +83,10 @@ // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(328, 90); + this.buttonCancel.Location = new System.Drawing.Point(287, 68); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(136, 40); + this.buttonCancel.Size = new System.Drawing.Size(119, 30); this.buttonCancel.TabIndex = 5; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; @@ -90,17 +94,18 @@ // // FormComponent // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(478, 142); + this.ClientSize = new System.Drawing.Size(418, 106); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonSave); this.Controls.Add(this.textBoxCost); this.Controls.Add(this.labelCost); this.Controls.Add(this.textBoxName); this.Controls.Add(this.labelName); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormComponent"; - this.Text = "Компонент"; + this.Text = "Ингридиент"; this.Load += new System.EventHandler(this.FormComponent_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/BankExecutor/BankExecutor/FormComponent.cs b/Pizzeria/Pizzeria/FormComponent.cs similarity index 90% rename from BankExecutor/BankExecutor/FormComponent.cs rename to Pizzeria/Pizzeria/FormComponent.cs index be0df5c..41fc5a2 100644 --- a/BankExecutor/BankExecutor/FormComponent.cs +++ b/Pizzeria/Pizzeria/FormComponent.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.Logging; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.BusinessLogicsContracts; -using BankExecutorContracts.SearchModels; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.SearchModels; using System.Windows.Forms; -namespace BankExecutorView +namespace PizzeriaView { public partial class FormComponent : Form { @@ -24,7 +24,7 @@ namespace BankExecutorView { try { - _logger.LogInformation("Получение компонента"); + _logger.LogInformation("Получение ингридиента"); var view = _logic.ReadElement(new ComponentSearchModel { Id = _id.Value @@ -37,7 +37,7 @@ namespace BankExecutorView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения компонента"); + _logger.LogError(ex, "Ошибка получения ингридиента"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -49,7 +49,7 @@ namespace BankExecutorView MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - _logger.LogInformation("Сохранение компонента"); + _logger.LogInformation("Сохранение ингридиента"); try { var model = new ComponentBindingModel @@ -69,7 +69,7 @@ namespace BankExecutorView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения компонента"); + _logger.LogError(ex, "Ошибка сохранения ингридиента"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,MessageBoxIcon.Error); } } diff --git a/BankExecutor/BankExecutor/FormComponent.resx b/Pizzeria/Pizzeria/FormComponent.resx similarity index 100% rename from BankExecutor/BankExecutor/FormComponent.resx rename to Pizzeria/Pizzeria/FormComponent.resx diff --git a/BankExecutor/BankExecutor/FormComponents.Designer.cs b/Pizzeria/Pizzeria/FormComponents.Designer.cs similarity index 53% rename from BankExecutor/BankExecutor/FormComponents.Designer.cs rename to Pizzeria/Pizzeria/FormComponents.Designer.cs index 1cb3083..878ed95 100644 --- a/BankExecutor/BankExecutor/FormComponents.Designer.cs +++ b/Pizzeria/Pizzeria/FormComponents.Designer.cs @@ -1,4 +1,4 @@ -namespace BankExecutorView +namespace PizzeriaView { partial class FormComponents { @@ -30,9 +30,9 @@ { this.dataGridView = new System.Windows.Forms.DataGridView(); this.ToolsPanel = new System.Windows.Forms.Panel(); - this.buttonRef = new System.Windows.Forms.Button(); - this.buttonDel = new System.Windows.Forms.Button(); - this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonUpdate = new System.Windows.Forms.Button(); + this.buttonDelete = new System.Windows.Forms.Button(); + this.buttonEdit = new System.Windows.Forms.Button(); this.buttonAdd = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.ToolsPanel.SuspendLayout(); @@ -43,60 +43,66 @@ this.dataGridView.AllowUserToAddRows = false; this.dataGridView.AllowUserToDeleteRows = false; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Location = new System.Drawing.Point(10, 9); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dataGridView.Name = "dataGridView"; this.dataGridView.ReadOnly = true; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(590, 426); + this.dataGridView.Size = new System.Drawing.Size(516, 320); this.dataGridView.TabIndex = 0; // // ToolsPanel // - this.ToolsPanel.Controls.Add(this.buttonRef); - this.ToolsPanel.Controls.Add(this.buttonDel); - this.ToolsPanel.Controls.Add(this.buttonUpd); + this.ToolsPanel.Controls.Add(this.buttonUpdate); + this.ToolsPanel.Controls.Add(this.buttonDelete); + this.ToolsPanel.Controls.Add(this.buttonEdit); this.ToolsPanel.Controls.Add(this.buttonAdd); - this.ToolsPanel.Location = new System.Drawing.Point(608, 12); + this.ToolsPanel.Location = new System.Drawing.Point(532, 9); + this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ToolsPanel.Name = "ToolsPanel"; - this.ToolsPanel.Size = new System.Drawing.Size(180, 426); + this.ToolsPanel.Size = new System.Drawing.Size(158, 320); this.ToolsPanel.TabIndex = 1; // - // buttonRef + // buttonUpdate // - this.buttonRef.Location = new System.Drawing.Point(31, 206); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(126, 36); - this.buttonRef.TabIndex = 3; - this.buttonRef.Text = "Обновить"; - this.buttonRef.UseVisualStyleBackColor = true; - this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + this.buttonUpdate.Location = new System.Drawing.Point(27, 154); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(110, 27); + this.buttonUpdate.TabIndex = 3; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); // - // buttonDel + // buttonDelete // - this.buttonDel.Location = new System.Drawing.Point(31, 142); - this.buttonDel.Name = "buttonDel"; - this.buttonDel.Size = new System.Drawing.Size(126, 36); - this.buttonDel.TabIndex = 2; - this.buttonDel.Text = "Удалить"; - this.buttonDel.UseVisualStyleBackColor = true; - this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); + this.buttonDelete.Location = new System.Drawing.Point(27, 106); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(110, 27); + this.buttonDelete.TabIndex = 2; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); // - // buttonUpd + // buttonEdit // - this.buttonUpd.Location = new System.Drawing.Point(31, 76); - this.buttonUpd.Name = "buttonUpd"; - this.buttonUpd.Size = new System.Drawing.Size(126, 36); - this.buttonUpd.TabIndex = 1; - this.buttonUpd.Text = "Изменить"; - this.buttonUpd.UseVisualStyleBackColor = true; - this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + this.buttonEdit.Location = new System.Drawing.Point(27, 57); + this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonEdit.Name = "buttonEdit"; + this.buttonEdit.Size = new System.Drawing.Size(110, 27); + this.buttonEdit.TabIndex = 1; + this.buttonEdit.Text = "Изменить"; + this.buttonEdit.UseVisualStyleBackColor = true; + this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click); // // buttonAdd // - this.buttonAdd.Location = new System.Drawing.Point(31, 16); + this.buttonAdd.Location = new System.Drawing.Point(27, 12); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(126, 36); + this.buttonAdd.Size = new System.Drawing.Size(110, 27); this.buttonAdd.TabIndex = 0; this.buttonAdd.Text = "Добавить"; this.buttonAdd.UseVisualStyleBackColor = true; @@ -104,13 +110,14 @@ // // FormComponents // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(700, 338); this.Controls.Add(this.ToolsPanel); this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormComponents"; - this.Text = "Компоненты"; + this.Text = "Ингредиенты"; this.Load += new System.EventHandler(this.FormComponents_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ToolsPanel.ResumeLayout(false); @@ -122,9 +129,9 @@ private DataGridView dataGridView; private Panel ToolsPanel; - private Button buttonRef; - private Button buttonDel; - private Button buttonUpd; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonEdit; private Button buttonAdd; } } \ No newline at end of file diff --git a/BankExecutor/BankExecutor/FormComponents.cs b/Pizzeria/Pizzeria/FormComponents.cs similarity index 90% rename from BankExecutor/BankExecutor/FormComponents.cs rename to Pizzeria/Pizzeria/FormComponents.cs index a88e92c..7d5b4d9 100644 --- a/BankExecutor/BankExecutor/FormComponents.cs +++ b/Pizzeria/Pizzeria/FormComponents.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Logging; -using BankExecutor; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.BusinessLogicsContracts; +using Pizzeria; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; using System; using System.Collections.Generic; using System.ComponentModel; @@ -12,7 +12,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace BankExecutorView +namespace PizzeriaView { public partial class FormComponents : Form { @@ -40,11 +40,11 @@ namespace BankExecutorView dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } - _logger.LogInformation("Загрузка компонентов"); + _logger.LogInformation("Загрузка ингридиентов"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки компонентов"); + _logger.LogError(ex, "Ошибка загрузки ингридиентов"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -85,7 +85,7 @@ namespace BankExecutorView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление компонента"); + _logger.LogInformation("Удаление ингридиента"); try { if (!_logic.Delete(new ComponentBindingModel @@ -99,7 +99,7 @@ namespace BankExecutorView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления компонента"); + _logger.LogError(ex, "Ошибка удаления ингридиента"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } diff --git a/BankExecutor/BankExecutor/FormComponents.resx b/Pizzeria/Pizzeria/FormComponents.resx similarity index 100% rename from BankExecutor/BankExecutor/FormComponents.resx rename to Pizzeria/Pizzeria/FormComponents.resx diff --git a/BankExecutor/BankExecutor/FormCreateOrder.Designer.cs b/Pizzeria/Pizzeria/FormCreateOrder.Designer.cs similarity index 80% rename from BankExecutor/BankExecutor/FormCreateOrder.Designer.cs rename to Pizzeria/Pizzeria/FormCreateOrder.Designer.cs index 090fe20..788c6ab 100644 --- a/BankExecutor/BankExecutor/FormCreateOrder.Designer.cs +++ b/Pizzeria/Pizzeria/FormCreateOrder.Designer.cs @@ -1,4 +1,4 @@ -namespace BankExecutorView +namespace PizzeriaView { partial class FormCreateOrder { @@ -28,8 +28,8 @@ /// private void InitializeComponent() { - this.labelProduct = new System.Windows.Forms.Label(); - this.comboBoxProduct = new System.Windows.Forms.ComboBox(); + this.labelPizza = new System.Windows.Forms.Label(); + this.comboBoxPizza = new System.Windows.Forms.ComboBox(); this.labelCount = new System.Windows.Forms.Label(); this.textBoxCount = new System.Windows.Forms.TextBox(); this.labelSum = new System.Windows.Forms.Label(); @@ -38,24 +38,24 @@ this.buttonSave = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // labelProduct + // labelPizza // - this.labelProduct.AutoSize = true; - this.labelProduct.Location = new System.Drawing.Point(10, 11); - this.labelProduct.Name = "labelProduct"; - this.labelProduct.Size = new System.Drawing.Size(59, 15); - this.labelProduct.TabIndex = 0; - this.labelProduct.Text = "Изделие: "; + this.labelPizza.AutoSize = true; + this.labelPizza.Location = new System.Drawing.Point(10, 11); + this.labelPizza.Name = "labelPizza"; + this.labelPizza.Size = new System.Drawing.Size(43, 15); + this.labelPizza.TabIndex = 0; + this.labelPizza.Text = "Пицца"; // - // comboBoxProduct + // comboBoxPizza // - this.comboBoxProduct.FormattingEnabled = true; - this.comboBoxProduct.Location = new System.Drawing.Point(101, 9); - this.comboBoxProduct.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.comboBoxProduct.Name = "comboBoxProduct"; - this.comboBoxProduct.Size = new System.Drawing.Size(314, 23); - this.comboBoxProduct.TabIndex = 1; - this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged); + this.comboBoxPizza.FormattingEnabled = true; + this.comboBoxPizza.Location = new System.Drawing.Point(101, 9); + this.comboBoxPizza.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxPizza.Name = "comboBoxPizza"; + this.comboBoxPizza.Size = new System.Drawing.Size(314, 23); + this.comboBoxPizza.TabIndex = 1; + this.comboBoxPizza.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPizza_SelectedIndexChanged); // // labelCount // @@ -126,8 +126,8 @@ this.Controls.Add(this.labelSum); this.Controls.Add(this.textBoxCount); this.Controls.Add(this.labelCount); - this.Controls.Add(this.comboBoxProduct); - this.Controls.Add(this.labelProduct); + this.Controls.Add(this.comboBoxPizza); + this.Controls.Add(this.labelPizza); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormCreateOrder"; this.Text = "Заказ"; @@ -139,8 +139,8 @@ #endregion - private Label labelProduct; - private ComboBox comboBoxProduct; + private Label labelPizza; + private ComboBox comboBoxPizza; private Label labelCount; private TextBox textBoxCount; private Label labelSum; diff --git a/BankExecutor/BankExecutor/FormCreateOrder.cs b/Pizzeria/Pizzeria/FormCreateOrder.cs similarity index 70% rename from BankExecutor/BankExecutor/FormCreateOrder.cs rename to Pizzeria/Pizzeria/FormCreateOrder.cs index 5311811..1acb535 100644 --- a/BankExecutor/BankExecutor/FormCreateOrder.cs +++ b/Pizzeria/Pizzeria/FormCreateOrder.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.Logging; using Microsoft.VisualBasic.Logging; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.BusinessLogicsContracts; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.ViewModels; -using BankExecutorListImplement.Models; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; +using PizzeriaListImplement.Models; using System; using System.Collections; using System.Collections.Generic; @@ -16,15 +16,15 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace BankExecutorView +namespace PizzeriaView { public partial class FormCreateOrder : Form { private readonly ILogger _logger; - private readonly IProductLogic _logicP; + private readonly IPizzaLogic _logicP; private readonly IOrderLogic _logicO; - private List? _list; - public FormCreateOrder(ILogger logger, IProductLogic logicP, IOrderLogic logicO) + private List? _list; + public FormCreateOrder(ILogger logger, IPizzaLogic logicP, IOrderLogic logicO) { InitializeComponent(); _logger = logger; @@ -36,26 +36,26 @@ namespace BankExecutorView _list = _logicP.ReadList(null); if (_list != null) { - comboBoxProduct.DisplayMember = "ProductName"; - comboBoxProduct.ValueMember = "Id"; - comboBoxProduct.DataSource = _list; - comboBoxProduct.SelectedItem = null; - _logger.LogInformation("Загрузка изделий для заказа"); + comboBoxPizza.DisplayMember = "PizzaName"; + comboBoxPizza.ValueMember = "Id"; + comboBoxPizza.DataSource = _list; + comboBoxPizza.SelectedItem = null; + _logger.LogInformation("Загрузка пиццы для заказа"); } } private void CalcSum() { - if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxPizza.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) { try { - int id = Convert.ToInt32(comboBoxProduct.SelectedValue); - var Product = _logicP.ReadElement(new ProductSearchModel + int id = Convert.ToInt32(comboBoxPizza.SelectedValue); + var Pizza = _logicP.ReadElement(new PizzaSearchModel { Id = id }); int count = Convert.ToInt32(textBoxCount.Text); - textBoxSum.Text = Math.Round(count * (Product?.Price ?? 0), 2).ToString(); + textBoxSum.Text = Math.Round(count * (Pizza?.Price ?? 0), 2).ToString(); _logger.LogInformation("Расчет суммы заказа"); } catch (Exception ex) @@ -69,7 +69,7 @@ namespace BankExecutorView { CalcSum(); } - private void ComboBoxProduct_SelectedIndexChanged(object sender, EventArgs e) + private void ComboBoxPizza_SelectedIndexChanged(object sender, EventArgs e) { CalcSum(); } @@ -80,9 +80,9 @@ namespace BankExecutorView MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (comboBoxProduct.SelectedValue == null) + if (comboBoxPizza.SelectedValue == null) { - MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _logger.LogInformation("Создание заказа"); @@ -90,7 +90,7 @@ namespace BankExecutorView { var operationResult = _logicO.CreateOrder(new OrderBindingModel { - ProductId = Convert.ToInt32(comboBoxProduct.SelectedValue), + PizzaId = Convert.ToInt32(comboBoxPizza.SelectedValue), Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/BankExecutor/BankExecutor/FormCreateOrder.resx b/Pizzeria/Pizzeria/FormCreateOrder.resx similarity index 100% rename from BankExecutor/BankExecutor/FormCreateOrder.resx rename to Pizzeria/Pizzeria/FormCreateOrder.resx diff --git a/BankExecutor/BankExecutor/FormMain.Designer.cs b/Pizzeria/Pizzeria/FormMain.Designer.cs similarity index 68% rename from BankExecutor/BankExecutor/FormMain.Designer.cs rename to Pizzeria/Pizzeria/FormMain.Designer.cs index 60f12b8..572f0a2 100644 --- a/BankExecutor/BankExecutor/FormMain.Designer.cs +++ b/Pizzeria/Pizzeria/FormMain.Designer.cs @@ -1,4 +1,4 @@ -namespace BankExecutorView +namespace PizzeriaView { partial class FormMain { @@ -29,9 +29,9 @@ private void InitializeComponent() { this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.справочникToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.bookToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ingridientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pizzasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); @@ -46,54 +46,57 @@ // this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникToolStripMenuItem}); + this.bookToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1313, 28); + this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); + this.menuStrip1.Size = new System.Drawing.Size(1149, 24); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // - // справочникToolStripMenuItem + // bookToolStripMenuItem // - this.справочникToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.компонентыToolStripMenuItem, - this.изделияToolStripMenuItem}); - this.справочникToolStripMenuItem.Name = "справочникToolStripMenuItem"; - this.справочникToolStripMenuItem.Size = new System.Drawing.Size(108, 24); - this.справочникToolStripMenuItem.Text = "Справочник"; + this.bookToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ingridientsToolStripMenuItem, + this.pizzasToolStripMenuItem}); + this.bookToolStripMenuItem.Name = "bookToolStripMenuItem"; + this.bookToolStripMenuItem.Size = new System.Drawing.Size(87, 20); + this.bookToolStripMenuItem.Text = "Справочник"; // - // компонентыToolStripMenuItem + // ingridientsToolStripMenuItem // - this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26); - this.компонентыToolStripMenuItem.Text = "Компоненты"; - this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); + this.ingridientsToolStripMenuItem.Name = "ingridientsToolStripMenuItem"; + this.ingridientsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.ingridientsToolStripMenuItem.Text = "Ингредиенты"; + this.ingridientsToolStripMenuItem.Click += new System.EventHandler(this.IngridentsToolStripMenuItem_Click); // - // изделияToolStripMenuItem + // pizzasToolStripMenuItem // - this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; - this.изделияToolStripMenuItem.Size = new System.Drawing.Size(182, 26); - this.изделияToolStripMenuItem.Text = "Изделия"; - this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click); + this.pizzasToolStripMenuItem.Name = "pizzasToolStripMenuItem"; + this.pizzasToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.pizzasToolStripMenuItem.Text = "Пиццы"; + this.pizzasToolStripMenuItem.Click += new System.EventHandler(this.PizzasToolStripMenuItem_Click); // // dataGridView // this.dataGridView.AllowUserToAddRows = false; this.dataGridView.AllowUserToDeleteRows = false; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 31); + this.dataGridView.Location = new System.Drawing.Point(10, 23); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dataGridView.Name = "dataGridView"; this.dataGridView.ReadOnly = true; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(977, 382); + this.dataGridView.Size = new System.Drawing.Size(855, 286); this.dataGridView.TabIndex = 1; // // buttonCreateOrder // - this.buttonCreateOrder.Location = new System.Drawing.Point(1026, 71); + this.buttonCreateOrder.Location = new System.Drawing.Point(898, 53); + this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCreateOrder.Name = "buttonCreateOrder"; - this.buttonCreateOrder.Size = new System.Drawing.Size(247, 29); + this.buttonCreateOrder.Size = new System.Drawing.Size(216, 22); this.buttonCreateOrder.TabIndex = 2; this.buttonCreateOrder.Text = "Создать заказ"; this.buttonCreateOrder.UseVisualStyleBackColor = true; @@ -101,9 +104,10 @@ // // buttonTakeOrderInWork // - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(1026, 122); + this.buttonTakeOrderInWork.Location = new System.Drawing.Point(898, 92); + this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - this.buttonTakeOrderInWork.Size = new System.Drawing.Size(247, 29); + this.buttonTakeOrderInWork.Size = new System.Drawing.Size(216, 22); this.buttonTakeOrderInWork.TabIndex = 3; this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; @@ -111,9 +115,10 @@ // // buttonOrderReady // - this.buttonOrderReady.Location = new System.Drawing.Point(1026, 172); + this.buttonOrderReady.Location = new System.Drawing.Point(898, 129); + this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonOrderReady.Name = "buttonOrderReady"; - this.buttonOrderReady.Size = new System.Drawing.Size(247, 29); + this.buttonOrderReady.Size = new System.Drawing.Size(216, 22); this.buttonOrderReady.TabIndex = 4; this.buttonOrderReady.Text = "Заказ готов"; this.buttonOrderReady.UseVisualStyleBackColor = true; @@ -121,9 +126,10 @@ // // buttonIssuedOrder // - this.buttonIssuedOrder.Location = new System.Drawing.Point(1026, 225); + this.buttonIssuedOrder.Location = new System.Drawing.Point(898, 169); + this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonIssuedOrder.Name = "buttonIssuedOrder"; - this.buttonIssuedOrder.Size = new System.Drawing.Size(247, 29); + this.buttonIssuedOrder.Size = new System.Drawing.Size(216, 22); this.buttonIssuedOrder.TabIndex = 5; this.buttonIssuedOrder.Text = "Заказ выдан"; this.buttonIssuedOrder.UseVisualStyleBackColor = true; @@ -131,9 +137,10 @@ // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(1026, 280); + this.buttonRef.Location = new System.Drawing.Point(898, 210); + this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(247, 29); + this.buttonRef.Size = new System.Drawing.Size(216, 22); this.buttonRef.TabIndex = 6; this.buttonRef.Text = "Обновить список"; this.buttonRef.UseVisualStyleBackColor = true; @@ -141,9 +148,9 @@ // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1313, 425); + this.ClientSize = new System.Drawing.Size(1149, 319); this.Controls.Add(this.buttonRef); this.Controls.Add(this.buttonIssuedOrder); this.Controls.Add(this.buttonOrderReady); @@ -152,8 +159,9 @@ this.Controls.Add(this.dataGridView); this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormMain"; - this.Text = "Завод железобетонных изделий"; + this.Text = "Пиццерия"; this.Load += new System.EventHandler(this.FormMain_Load); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); @@ -166,9 +174,9 @@ #endregion private MenuStrip menuStrip1; - private ToolStripMenuItem справочникToolStripMenuItem; - private ToolStripMenuItem компонентыToolStripMenuItem; - private ToolStripMenuItem изделияToolStripMenuItem; + private ToolStripMenuItem bookToolStripMenuItem; + private ToolStripMenuItem ingridientsToolStripMenuItem; + private ToolStripMenuItem pizzasToolStripMenuItem; private DataGridView dataGridView; private Button buttonCreateOrder; private Button buttonTakeOrderInWork; diff --git a/BankExecutor/BankExecutor/FormMain.cs b/Pizzeria/Pizzeria/FormMain.cs similarity index 91% rename from BankExecutor/BankExecutor/FormMain.cs rename to Pizzeria/Pizzeria/FormMain.cs index 8e25977..736f66e 100644 --- a/BankExecutor/BankExecutor/FormMain.cs +++ b/Pizzeria/Pizzeria/FormMain.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Logging; -using BankExecutor; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.BusinessLogicsContracts; +using Pizzeria; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; using System; using System.Collections.Generic; using System.ComponentModel; @@ -12,7 +12,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace BankExecutorView +namespace PizzeriaView { public partial class FormMain : Form { @@ -36,8 +36,8 @@ namespace BankExecutorView if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["ProductId"].Visible = false; - dataGridView.Columns["ProductName"].AutoSizeMode = + dataGridView.Columns["PizzaId"].Visible = false; + dataGridView.Columns["PizzaName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); @@ -48,7 +48,7 @@ namespace BankExecutorView MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) + private void IngridentsToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); if (service is FormComponents form) @@ -56,10 +56,10 @@ namespace BankExecutorView form.ShowDialog(); } } - private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) + private void PizzasToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormProducts)); - if (service is FormProducts form) + var service = Program.ServiceProvider?.GetService(typeof(FormPizzas)); + if (service is FormPizzas form) { form.ShowDialog(); } diff --git a/BankExecutor/BankExecutor/FormMain.resx b/Pizzeria/Pizzeria/FormMain.resx similarity index 100% rename from BankExecutor/BankExecutor/FormMain.resx rename to Pizzeria/Pizzeria/FormMain.resx diff --git a/BankExecutor/BankExecutor/FormProduct.Designer.cs b/Pizzeria/Pizzeria/FormPizza.Designer.cs similarity index 77% rename from BankExecutor/BankExecutor/FormProduct.Designer.cs rename to Pizzeria/Pizzeria/FormPizza.Designer.cs index 1f2cccb..a906809 100644 --- a/BankExecutor/BankExecutor/FormProduct.Designer.cs +++ b/Pizzeria/Pizzeria/FormPizza.Designer.cs @@ -1,6 +1,6 @@ -namespace BankExecutorView +namespace PizzeriaView { - partial class FormProduct + partial class FormPizza { /// /// Required designer variable. @@ -50,33 +50,35 @@ // labelName // this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(16, 15); + this.labelName.Location = new System.Drawing.Point(14, 11); this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(84, 20); + this.labelName.Size = new System.Drawing.Size(65, 15); this.labelName.TabIndex = 0; this.labelName.Text = "Название: "; // // textBoxName // - this.textBoxName.Location = new System.Drawing.Point(112, 12); + this.textBoxName.Location = new System.Drawing.Point(98, 9); + this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(293, 27); + this.textBoxName.Size = new System.Drawing.Size(257, 23); this.textBoxName.TabIndex = 1; // // labelPrice // this.labelPrice.AutoSize = true; - this.labelPrice.Location = new System.Drawing.Point(16, 51); + this.labelPrice.Location = new System.Drawing.Point(14, 38); this.labelPrice.Name = "labelPrice"; - this.labelPrice.Size = new System.Drawing.Size(90, 20); + this.labelPrice.Size = new System.Drawing.Size(73, 15); this.labelPrice.TabIndex = 2; this.labelPrice.Text = "Стоимость: "; // // textBoxPrice // - this.textBoxPrice.Location = new System.Drawing.Point(112, 51); + this.textBoxPrice.Location = new System.Drawing.Point(98, 38); + this.textBoxPrice.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxPrice.Name = "textBoxPrice"; - this.textBoxPrice.Size = new System.Drawing.Size(171, 27); + this.textBoxPrice.Size = new System.Drawing.Size(150, 23); this.textBoxPrice.TabIndex = 3; // // groupBoxComponents @@ -86,18 +88,21 @@ this.groupBoxComponents.Controls.Add(this.buttonUpd); this.groupBoxComponents.Controls.Add(this.buttonAdd); this.groupBoxComponents.Controls.Add(this.dataGridView); - this.groupBoxComponents.Location = new System.Drawing.Point(12, 84); + this.groupBoxComponents.Location = new System.Drawing.Point(10, 63); + this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.groupBoxComponents.Name = "groupBoxComponents"; - this.groupBoxComponents.Size = new System.Drawing.Size(661, 319); + this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.groupBoxComponents.Size = new System.Drawing.Size(578, 239); this.groupBoxComponents.TabIndex = 4; this.groupBoxComponents.TabStop = false; - this.groupBoxComponents.Text = "Компоненты"; + this.groupBoxComponents.Text = "Ингредиенты"; // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(502, 211); + this.buttonRef.Location = new System.Drawing.Point(439, 158); + this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(126, 34); + this.buttonRef.Size = new System.Drawing.Size(110, 26); this.buttonRef.TabIndex = 4; this.buttonRef.Text = "Обновить"; this.buttonRef.UseVisualStyleBackColor = true; @@ -105,9 +110,10 @@ // // buttonDel // - this.buttonDel.Location = new System.Drawing.Point(502, 157); + this.buttonDel.Location = new System.Drawing.Point(439, 118); + this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonDel.Name = "buttonDel"; - this.buttonDel.Size = new System.Drawing.Size(126, 34); + this.buttonDel.Size = new System.Drawing.Size(110, 26); this.buttonDel.TabIndex = 3; this.buttonDel.Text = "Удалить"; this.buttonDel.UseVisualStyleBackColor = true; @@ -115,9 +121,10 @@ // // buttonUpd // - this.buttonUpd.Location = new System.Drawing.Point(502, 102); + this.buttonUpd.Location = new System.Drawing.Point(439, 76); + this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonUpd.Name = "buttonUpd"; - this.buttonUpd.Size = new System.Drawing.Size(126, 34); + this.buttonUpd.Size = new System.Drawing.Size(110, 26); this.buttonUpd.TabIndex = 2; this.buttonUpd.Text = "Изменить"; this.buttonUpd.UseVisualStyleBackColor = true; @@ -125,9 +132,10 @@ // // buttonAdd // - this.buttonAdd.Location = new System.Drawing.Point(502, 47); + this.buttonAdd.Location = new System.Drawing.Point(439, 35); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(126, 34); + this.buttonAdd.Size = new System.Drawing.Size(110, 26); this.buttonAdd.TabIndex = 1; this.buttonAdd.Text = "Добавить"; this.buttonAdd.UseVisualStyleBackColor = true; @@ -143,19 +151,21 @@ this.id, this.Component, this.Count}); - this.dataGridView.Location = new System.Drawing.Point(6, 26); + this.dataGridView.Location = new System.Drawing.Point(5, 20); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.dataGridView.Name = "dataGridView"; this.dataGridView.ReadOnly = true; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(476, 287); + this.dataGridView.Size = new System.Drawing.Size(416, 215); this.dataGridView.TabIndex = 0; // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(514, 417); + this.buttonCancel.Location = new System.Drawing.Point(450, 313); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(126, 34); + this.buttonCancel.Size = new System.Drawing.Size(110, 26); this.buttonCancel.TabIndex = 5; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; @@ -163,9 +173,10 @@ // // buttonSave // - this.buttonSave.Location = new System.Drawing.Point(368, 417); + this.buttonSave.Location = new System.Drawing.Point(322, 313); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(126, 34); + this.buttonSave.Size = new System.Drawing.Size(110, 26); this.buttonSave.TabIndex = 6; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; @@ -181,7 +192,7 @@ // // Component // - this.Component.HeaderText = "Компонент"; + this.Component.HeaderText = "Ингредиент"; this.Component.MinimumWidth = 6; this.Component.Name = "Component"; this.Component.ReadOnly = true; @@ -193,11 +204,11 @@ this.Count.Name = "Count"; this.Count.ReadOnly = true; // - // FormProduct + // FormPizza // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(685, 463); + this.ClientSize = new System.Drawing.Size(599, 347); this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.groupBoxComponents); @@ -205,9 +216,10 @@ this.Controls.Add(this.labelPrice); this.Controls.Add(this.textBoxName); this.Controls.Add(this.labelName); - this.Name = "FormProduct"; - this.Text = "Изделие"; - this.Load += new System.EventHandler(this.FormProduct_Load); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormPizza"; + this.Text = "Пицца"; + this.Load += new System.EventHandler(this.FormPizza_Load); this.groupBoxComponents.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); @@ -228,10 +240,10 @@ private Button buttonUpd; private Button buttonAdd; private DataGridView dataGridView; - private DataGridViewTextBoxColumn Component; - private DataGridViewTextBoxColumn Count; private Button buttonCancel; private Button buttonSave; private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Count; } } \ No newline at end of file diff --git a/BankExecutor/BankExecutor/FormProduct.cs b/Pizzeria/Pizzeria/FormPizza.cs similarity index 69% rename from BankExecutor/BankExecutor/FormProduct.cs rename to Pizzeria/Pizzeria/FormPizza.cs index 1e92c9b..a1df7be 100644 --- a/BankExecutor/BankExecutor/FormProduct.cs +++ b/Pizzeria/Pizzeria/FormPizza.cs @@ -1,9 +1,9 @@ -using BankExecutorDataModels.Models; -using BankExecutor; +using PizzeriaDataModels.Models; +using Pizzeria; using Microsoft.Extensions.Logging; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.BusinessLogicsContracts; -using BankExecutorContracts.SearchModels; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.SearchModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -14,45 +14,45 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace BankExecutorView +namespace PizzeriaView { - public partial class FormProduct : Form + public partial class FormPizza : Form { private readonly ILogger _logger; - private readonly IProductLogic _logic; + private readonly IPizzaLogic _logic; private int? _id; - private Dictionary _ProductComponents; + private Dictionary _PizzaComponents; public int Id { set { _id = value; } } - public FormProduct(ILogger logger, IProductLogic logic) + public FormPizza(ILogger logger, IPizzaLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _ProductComponents = new Dictionary(); + _PizzaComponents = new Dictionary(); } - private void FormProduct_Load(object sender, EventArgs e) + private void FormPizza_Load(object sender, EventArgs e) { if (_id.HasValue) { - _logger.LogInformation("Загрузка изделия"); + _logger.LogInformation("Загрузка пиццы"); try { - var view = _logic.ReadElement(new ProductSearchModel + var view = _logic.ReadElement(new PizzaSearchModel { Id = _id.Value }); if (view != null) { - textBoxName.Text = view.ProductName; + textBoxName.Text = view.PizzaName; textBoxPrice.Text = view.Price.ToString(); - _ProductComponents = view.ProductComponents ?? new + _PizzaComponents = view.PizzaComponents ?? new Dictionary(); LoadData(); } } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки изделия"); + _logger.LogError(ex, "Ошибка загрузки пиццы"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -60,13 +60,13 @@ namespace BankExecutorView } private void LoadData() { - _logger.LogInformation("Загрузка компонент изделия"); + _logger.LogInformation("Загрузка ингредиент пиццы"); try { - if (_ProductComponents != null) + if (_PizzaComponents != null) { dataGridView.Rows.Clear(); - foreach (var pc in _ProductComponents) + foreach (var pc in _PizzaComponents) { dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); } @@ -75,15 +75,15 @@ namespace BankExecutorView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + _logger.LogError(ex, "Ошибка загрузки ингредиента пиццы"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent)); - if (service is FormProductComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormPizzaComponent)); + if (service is FormPizzaComponent form) { if (form.ShowDialog() == DialogResult.OK) { @@ -91,15 +91,15 @@ namespace BankExecutorView { return; } - _logger.LogInformation("Добавление нового компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); - if (_ProductComponents.ContainsKey(form.Id)) + _logger.LogInformation("Добавление нового ингредиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); + if (_PizzaComponents.ContainsKey(form.Id)) { - _ProductComponents[form.Id] = (form.ComponentModel, + _PizzaComponents[form.Id] = (form.ComponentModel, form.Count); } else { - _ProductComponents.Add(form.Id, (form.ComponentModel, + _PizzaComponents.Add(form.Id, (form.ComponentModel, form.Count)); } LoadData(); @@ -110,20 +110,20 @@ namespace BankExecutorView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent)); - if (service is FormProductComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormPizzaComponent)); + if (service is FormPizzaComponent form) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _ProductComponents[id].Item2; + form.Count = _PizzaComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) { return; } - _logger.LogInformation("Изменение компонента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); - _ProductComponents[form.Id] = (form.ComponentModel, form.Count); + _logger.LogInformation("Изменение ингредиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); + _PizzaComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } @@ -137,8 +137,8 @@ namespace BankExecutorView { try { - _logger.LogInformation("Удаление компонента:{ ComponentName}-{ Count}", dataGridView.SelectedRows[0].Cells[1].Value); - _ProductComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _logger.LogInformation("Удаление ингредиента:{ ComponentName}-{ Count}", dataGridView.SelectedRows[0].Cells[1].Value); + _PizzaComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -165,20 +165,20 @@ namespace BankExecutorView MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (_ProductComponents == null || _ProductComponents.Count == 0) + if (_PizzaComponents == null || _PizzaComponents.Count == 0) { - MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните ингредиенты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - _logger.LogInformation("Сохранение изделия"); + _logger.LogInformation("Сохранение пиццы"); try { - var model = new ProductBindingModel + var model = new PizzaBindingModel { Id = _id ?? 0, - ProductName = textBoxName.Text, + PizzaName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - ProductComponents = _ProductComponents + PizzaComponents = _PizzaComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); @@ -192,7 +192,7 @@ namespace BankExecutorView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения изделия"); + _logger.LogError(ex, "Ошибка сохранения пиццы"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -204,7 +204,7 @@ namespace BankExecutorView private double CalcPrice() { double price = 0; - foreach (var elem in _ProductComponents) + foreach (var elem in _PizzaComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/BankExecutor/BankExecutor/FormProductComponent.resx b/Pizzeria/Pizzeria/FormPizza.resx similarity index 100% rename from BankExecutor/BankExecutor/FormProductComponent.resx rename to Pizzeria/Pizzeria/FormPizza.resx diff --git a/BankExecutor/BankExecutor/FormProductComponent.Designer.cs b/Pizzeria/Pizzeria/FormPizzaComponent.Designer.cs similarity index 77% rename from BankExecutor/BankExecutor/FormProductComponent.Designer.cs rename to Pizzeria/Pizzeria/FormPizzaComponent.Designer.cs index ec749ac..6cf9597 100644 --- a/BankExecutor/BankExecutor/FormProductComponent.Designer.cs +++ b/Pizzeria/Pizzeria/FormPizzaComponent.Designer.cs @@ -1,6 +1,6 @@ -namespace BankExecutorView +namespace PizzeriaView { - partial class FormProductComponent + partial class FormPizzaComponent { /// /// Required designer variable. @@ -39,41 +39,44 @@ // labelComponent // this.labelComponent.AutoSize = true; - this.labelComponent.Location = new System.Drawing.Point(12, 9); + this.labelComponent.Location = new System.Drawing.Point(10, 7); this.labelComponent.Name = "labelComponent"; - this.labelComponent.Size = new System.Drawing.Size(91, 20); + this.labelComponent.Size = new System.Drawing.Size(75, 15); this.labelComponent.TabIndex = 0; - this.labelComponent.Text = "Компонент:"; + this.labelComponent.Text = "Ингредиент:"; // // comboBoxComponent // this.comboBoxComponent.FormattingEnabled = true; - this.comboBoxComponent.Location = new System.Drawing.Point(119, 9); + this.comboBoxComponent.Location = new System.Drawing.Point(104, 7); + this.comboBoxComponent.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.comboBoxComponent.Name = "comboBoxComponent"; - this.comboBoxComponent.Size = new System.Drawing.Size(355, 28); + this.comboBoxComponent.Size = new System.Drawing.Size(311, 23); this.comboBoxComponent.TabIndex = 1; // // labelCount // this.labelCount.AutoSize = true; - this.labelCount.Location = new System.Drawing.Point(12, 51); + this.labelCount.Location = new System.Drawing.Point(10, 38); this.labelCount.Name = "labelCount"; - this.labelCount.Size = new System.Drawing.Size(93, 20); + this.labelCount.Size = new System.Drawing.Size(75, 15); this.labelCount.TabIndex = 2; this.labelCount.Text = "Количество:"; // // textBoxCount // - this.textBoxCount.Location = new System.Drawing.Point(119, 51); + this.textBoxCount.Location = new System.Drawing.Point(104, 38); + this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.textBoxCount.Name = "textBoxCount"; - this.textBoxCount.Size = new System.Drawing.Size(355, 27); + this.textBoxCount.Size = new System.Drawing.Size(311, 23); this.textBoxCount.TabIndex = 3; // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(317, 94); + this.buttonCancel.Location = new System.Drawing.Point(277, 70); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(136, 41); + this.buttonCancel.Size = new System.Drawing.Size(119, 31); this.buttonCancel.TabIndex = 4; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; @@ -81,27 +84,29 @@ // // buttonSave // - this.buttonSave.Location = new System.Drawing.Point(175, 94); + this.buttonSave.Location = new System.Drawing.Point(153, 70); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(136, 41); + this.buttonSave.Size = new System.Drawing.Size(119, 31); this.buttonSave.TabIndex = 5; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // - // FormProductComponent + // FormPizzaComponent // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(486, 147); + this.ClientSize = new System.Drawing.Size(425, 110); this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.textBoxCount); this.Controls.Add(this.labelCount); this.Controls.Add(this.comboBoxComponent); this.Controls.Add(this.labelComponent); - this.Name = "FormProductComponent"; - this.Text = "Компонент изделия"; + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormPizzaComponent"; + this.Text = "Ингридиент пиццы"; this.ResumeLayout(false); this.PerformLayout(); diff --git a/BankExecutor/BankExecutor/FormProductComponent.cs b/Pizzeria/Pizzeria/FormPizzaComponent.cs similarity index 84% rename from BankExecutor/BankExecutor/FormProductComponent.cs rename to Pizzeria/Pizzeria/FormPizzaComponent.cs index 4006e6a..bce3713 100644 --- a/BankExecutor/BankExecutor/FormProductComponent.cs +++ b/Pizzeria/Pizzeria/FormPizzaComponent.cs @@ -1,7 +1,7 @@ -using BankExecutorDataModels.Models; +using PizzeriaDataModels.Models; using Microsoft.VisualBasic.Logging; -using BankExecutorContracts.BusinessLogicsContracts; -using BankExecutorContracts.ViewModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.ViewModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -12,9 +12,9 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace BankExecutorView +namespace PizzeriaView { - public partial class FormProductComponent : Form + public partial class FormPizzaComponent : Form { private readonly List? _list; public int Id @@ -47,7 +47,7 @@ namespace BankExecutorView } } public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set{ textBoxCount.Text = value.ToString(); }} - public FormProductComponent(IComponentLogic logic) + public FormPizzaComponent(IComponentLogic logic) { InitializeComponent(); @@ -69,7 +69,7 @@ namespace BankExecutorView } if (comboBoxComponent.SelectedValue == null) { - MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Выберите ингредиент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult = DialogResult.OK; diff --git a/BankExecutor/BankExecutor/FormProducts.resx b/Pizzeria/Pizzeria/FormPizzaComponent.resx similarity index 100% rename from BankExecutor/BankExecutor/FormProducts.resx rename to Pizzeria/Pizzeria/FormPizzaComponent.resx diff --git a/BankExecutor/BankExecutor/FormProducts.Designer.cs b/Pizzeria/Pizzeria/FormPizzas.Designer.cs similarity index 95% rename from BankExecutor/BankExecutor/FormProducts.Designer.cs rename to Pizzeria/Pizzeria/FormPizzas.Designer.cs index 8a10ba1..23f97ae 100644 --- a/BankExecutor/BankExecutor/FormProducts.Designer.cs +++ b/Pizzeria/Pizzeria/FormPizzas.Designer.cs @@ -1,6 +1,6 @@ -namespace BankExecutorView +namespace PizzeriaView { - partial class FormProducts + partial class FormPizzas { /// /// Required designer variable. @@ -102,16 +102,16 @@ this.dataGridView.Size = new System.Drawing.Size(590, 426); this.dataGridView.TabIndex = 2; // - // FormProducts + // FormPizzas // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); this.Controls.Add(this.ToolsPanel); this.Controls.Add(this.dataGridView); - this.Name = "FormProducts"; - this.Text = "Изделия"; - this.Load += new System.EventHandler(this.FormProduct_Load); + this.Name = "FormPizzas"; + this.Text = "Пицца"; + this.Load += new System.EventHandler(this.FormPizza_Load); this.ToolsPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/BankExecutor/BankExecutor/FormProducts.cs b/Pizzeria/Pizzeria/FormPizzas.cs similarity index 76% rename from BankExecutor/BankExecutor/FormProducts.cs rename to Pizzeria/Pizzeria/FormPizzas.cs index a79ff26..cf2cc73 100644 --- a/BankExecutor/BankExecutor/FormProducts.cs +++ b/Pizzeria/Pizzeria/FormPizzas.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Logging; -using BankExecutor; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.BusinessLogicsContracts; +using Pizzeria; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; using System; using System.Collections.Generic; using System.ComponentModel; @@ -12,19 +12,19 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace BankExecutorView +namespace PizzeriaView { - public partial class FormProducts : Form + public partial class FormPizzas : Form { private readonly ILogger _logger; - private readonly IProductLogic _logic; - public FormProducts(ILogger logger, IProductLogic logic) + private readonly IPizzaLogic _logic; + public FormPizzas(ILogger logger, IPizzaLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormProduct_Load(object sender, EventArgs e) + private void FormPizza_Load(object sender, EventArgs e) { LoadData(); } @@ -37,22 +37,22 @@ namespace BankExecutorView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ProductComponents"].Visible = false; - dataGridView.Columns["ProductName"].AutoSizeMode = + dataGridView.Columns["PizzaComponents"].Visible = false; + dataGridView.Columns["PizzaName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } - _logger.LogInformation("Загрузка изделий"); + _logger.LogInformation("Загрузка пиццы"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки изделий"); + _logger.LogError(ex, "Ошибка загрузки пиццы"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormProduct)); - if (service is FormProduct form) + var service = Program.ServiceProvider?.GetService(typeof(FormPizza)); + if (service is FormPizza form) { if (form.ShowDialog() == DialogResult.OK) { @@ -64,8 +64,8 @@ namespace BankExecutorView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormProduct)); - if (service is FormProduct form) + var service = Program.ServiceProvider?.GetService(typeof(FormPizza)); + if (service is FormPizza form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -82,10 +82,10 @@ namespace BankExecutorView if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Удаление изделия"); + _logger.LogInformation("Удаление пиццы"); try { - if (!_logic.Delete(new ProductBindingModel + if (!_logic.Delete(new PizzaBindingModel { Id = id })) @@ -96,7 +96,7 @@ namespace BankExecutorView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления изделия"); + _logger.LogError(ex, "Ошибка удаления пиццы"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/Pizzeria/Pizzeria/FormPizzas.resx b/Pizzeria/Pizzeria/FormPizzas.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Pizzeria/Pizzeria/FormPizzas.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BankExecutor/BankExecutor/BankExecutorView.csproj b/Pizzeria/Pizzeria/PizzeriaView.csproj similarity index 53% rename from BankExecutor/BankExecutor/BankExecutorView.csproj rename to Pizzeria/Pizzeria/PizzeriaView.csproj index 9b470cc..e6472cf 100644 --- a/BankExecutor/BankExecutor/BankExecutorView.csproj +++ b/Pizzeria/Pizzeria/PizzeriaView.csproj @@ -14,10 +14,11 @@ - - - - + + + + + \ No newline at end of file diff --git a/BankExecutor/BankExecutor/Program.cs b/Pizzeria/Pizzeria/Program.cs similarity index 74% rename from BankExecutor/BankExecutor/Program.cs rename to Pizzeria/Pizzeria/Program.cs index 8629703..51dc067 100644 --- a/BankExecutor/BankExecutor/Program.cs +++ b/Pizzeria/Pizzeria/Program.cs @@ -1,16 +1,16 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -using BankExecutorBusinessLogic.BusinessLogics; -using BankExecutorContracts.BusinessLogicsContracts; -using BankExecutorContracts.StoragesContracts; -using BankExecutorListImplement.Implements; -using BankExecutorView; +using PizzeriaBusinessLogic.BusinessLogics; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.StoragesContracts; +using PizzeriaListImplement.Implements; +using PizzeriaView; using System; using System.Drawing; -using BankExecutortBusinessLogic.BusinessLogics; +using PizzeriatBusinessLogic.BusinessLogics; -namespace BankExecutor +namespace Pizzeria { internal static class Program { @@ -40,17 +40,17 @@ namespace BankExecutor services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/BankExecutor/BankExecutor/nlog.config b/Pizzeria/Pizzeria/nlog.config similarity index 100% rename from BankExecutor/BankExecutor/nlog.config rename to Pizzeria/Pizzeria/nlog.config diff --git a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ComponentLogic.cs b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ComponentLogic.cs similarity index 85% rename from BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ComponentLogic.cs rename to Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ComponentLogic.cs index d3b7e21..8a5ad62 100644 --- a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/ComponentLogic.cs +++ b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ComponentLogic.cs @@ -1,11 +1,11 @@ -using BankExecutorContracts.BusinessLogicsContracts; -using BankExecutorContracts.StoragesContracts; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.StoragesContracts; using Microsoft.Extensions.Logging; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.ViewModels; -using BankExecutorContracts.SearchModels; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.ViewModels; +using PizzeriaContracts.SearchModels; -namespace BankExecutorBusinessLogic.BusinessLogics +namespace PizzeriaBusinessLogic.BusinessLogics { public class ComponentLogic : IComponentLogic { @@ -87,11 +87,11 @@ namespace BankExecutorBusinessLogic.BusinessLogics } if (string.IsNullOrEmpty(model.ComponentName)) { - throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName)); + throw new ArgumentNullException("Нет названия ингредиента", nameof(model.ComponentName)); } if (model.Cost <= 0) { - throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + throw new ArgumentNullException("Цена ингредиента должна быть больше 0", nameof(model.Cost)); } _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}.Id: { Id}", model.ComponentName, model.Cost, model.Id); var element = _componentStorage.GetElement(new ComponentSearchModel @@ -100,7 +100,7 @@ namespace BankExecutorBusinessLogic.BusinessLogics }); if (element != null && element.Id != model.Id) { - throw new InvalidOperationException("Компонент с таким названием уже есть"); + throw new InvalidOperationException("Ингредиент с таким названием уже есть"); } } } diff --git a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/OrderLogic.cs b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/OrderLogic.cs similarity index 86% rename from BankExecutor/BankExecutorBusinessLogic/BusinessLogics/OrderLogic.cs rename to Pizzeria/PizzeriaBusinessLogic/BusinessLogics/OrderLogic.cs index 387bd88..c9335e2 100644 --- a/BankExecutor/BankExecutorBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/OrderLogic.cs @@ -1,12 +1,12 @@ -using BankExecutorDataModels.Enums; +using PizzeriaDataModels.Enums; using Microsoft.Extensions.Logging; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.BusinessLogicsContracts; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.StoragesContracts; -using BankExecutorContracts.ViewModels; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.StoragesContracts; +using PizzeriaContracts.ViewModels; -namespace BankExecutortBusinessLogic.BusinessLogics +namespace PizzeriatBusinessLogic.BusinessLogics { public class OrderLogic : IOrderLogic { @@ -66,7 +66,7 @@ namespace BankExecutortBusinessLogic.BusinessLogics } if (model.Count <= 0) { - throw new ArgumentException("Колличество изделий в заказе не может быть меньше 1", nameof(model.Count)); + throw new ArgumentException("Колличество пиццы в заказе не может быть меньше 1", nameof(model.Count)); } if (model.Sum <= 0) { @@ -76,8 +76,8 @@ namespace BankExecutortBusinessLogic.BusinessLogics { throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}"); } - _logger.LogInformation("Product. ProductId:{ProductId}.Count:{Count}.Sum:{Sum}Id:{Id}", - model.ProductId, model.Count,model.Sum, model.Id); + _logger.LogInformation("Pizza. PizzaId:{PizzaId}.Count:{Count}.Sum:{Sum}Id:{Id}", + model.PizzaId, model.Count,model.Sum, model.Id); } private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) { CheckModel(model, false); @@ -90,7 +90,7 @@ namespace BankExecutortBusinessLogic.BusinessLogics throw new ArgumentNullException(nameof(element)); } model.DateCreate = element.DateCreate; - model.ProductId = element.ProductId; + model.PizzaId = element.PizzaId; model.DateImplement = element.DateImplement; model.Status = element.Status; model.Count = element.Count; diff --git a/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/PizzaLogic.cs b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/PizzaLogic.cs new file mode 100644 index 0000000..a3f5300 --- /dev/null +++ b/Pizzeria/PizzeriaBusinessLogic/BusinessLogics/PizzaLogic.cs @@ -0,0 +1,111 @@ +using Microsoft.Extensions.Logging; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.BusinessLogicsContracts; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.StoragesContracts; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaBusinessLogic.BusinessLogics +{ + public class PizzaLogic : IPizzaLogic + { + private readonly ILogger _logger; + private readonly IPizzaStorage _PizzaStorage; + public PizzaLogic(ILogger logger, IPizzaStorage PizzaStorage) + { + _logger = logger; + _PizzaStorage= PizzaStorage; + } + public List? ReadList(PizzaSearchModel? model) + { + _logger.LogInformation("ReadList. PizzaName:{PizzaName}.Id:{ Id}", model?.PizzaName, model?.Id); + var list = model == null ? _PizzaStorage.GetFullList() : _PizzaStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public PizzaViewModel? ReadElement(PizzaSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. PizzaName:{PizzaName}.Id:{ Id}", model.PizzaName, model.Id); + var element = _PizzaStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + public bool Create(PizzaBindingModel model) + { + CheckModel(model); + if (_PizzaStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(PizzaBindingModel model) + { + CheckModel(model); + if (_PizzaStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(PizzaBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_PizzaStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(PizzaBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.PizzaName)) + { + throw new ArgumentNullException("Нет названия пиццы", nameof(model.PizzaName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена пиццы должна быть больше 0", nameof(model.Price)); + } + if(model.PizzaComponents==null || model.PizzaComponents.Count == 0) + { + throw new ArgumentNullException("Перечень ингредиентов не может быть пустым", nameof(model.PizzaComponents)); + } + _logger.LogInformation("Pizza. PizzaName:{PizzaName}.Price:{Price}.Id: { Id}", model.PizzaName, model.Price, model.Id); + var element = _PizzaStorage.GetElement(new PizzaSearchModel + { + PizzaName = model.PizzaName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Пицца с таким названием уже есть"); + } + } + } +} diff --git a/BankExecutor/BankExecutorBusinessLogic/BankExecutorBusinessLogic.csproj b/Pizzeria/PizzeriaBusinessLogic/PizzeriaBusinessLogic.csproj similarity index 71% rename from BankExecutor/BankExecutorBusinessLogic/BankExecutorBusinessLogic.csproj rename to Pizzeria/PizzeriaBusinessLogic/PizzeriaBusinessLogic.csproj index 3ed4d1a..4e3f741 100644 --- a/BankExecutor/BankExecutorBusinessLogic/BankExecutorBusinessLogic.csproj +++ b/Pizzeria/PizzeriaBusinessLogic/PizzeriaBusinessLogic.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -11,7 +11,7 @@ - + diff --git a/BankExecutor/BankExecutorContracts/BindingModels/ComponentBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs similarity index 71% rename from BankExecutor/BankExecutorContracts/BindingModels/ComponentBindingModel.cs rename to Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs index b356102..efc8a2b 100644 --- a/BankExecutor/BankExecutorContracts/BindingModels/ComponentBindingModel.cs +++ b/Pizzeria/PizzeriaContracts/BindingModels/ComponentBindingModel.cs @@ -1,6 +1,6 @@ -using BankExecutorDataModels.Models; +using PizzeriaDataModels.Models; -namespace BankExecutorContracts.BindingModels +namespace PizzeriaContracts.BindingModels { public class ComponentBindingModel : IComponentModel { diff --git a/BankExecutor/BankExecutorContracts/BindingModels/OrderBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs similarity index 69% rename from BankExecutor/BankExecutorContracts/BindingModels/OrderBindingModel.cs rename to Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs index 77b757f..2aa57dc 100644 --- a/BankExecutor/BankExecutorContracts/BindingModels/OrderBindingModel.cs +++ b/Pizzeria/PizzeriaContracts/BindingModels/OrderBindingModel.cs @@ -1,12 +1,12 @@ -using BankExecutorDataModels.Enums; -using BankExecutorDataModels.Models; +using PizzeriaDataModels.Enums; +using PizzeriaDataModels.Models; -namespace BankExecutorContracts.BindingModels +namespace PizzeriaContracts.BindingModels { public class OrderBindingModel : IOrderModel { public int Id { get; set; } - public int ProductId { get; set; } + public int PizzaId { get; set; } public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs b/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs new file mode 100644 index 0000000..fc74c3d --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BindingModels/PizzaBindingModel.cs @@ -0,0 +1,13 @@ +using PizzeriaDataModels.Models; + +namespace PizzeriaContracts.BindingModels +{ + public class PizzaBindingModel : IPizzaModel + { + public int Id { get; set; } + public string PizzaName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary PizzaComponents { get; set; } = new(); + + } +} diff --git a/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IComponentLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs similarity index 65% rename from BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IComponentLogic.cs rename to Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs index 51f214f..4f4412d 100644 --- a/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IComponentLogic.cs +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -1,8 +1,8 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.ViewModels; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; -namespace BankExecutorContracts.BusinessLogicsContracts +namespace PizzeriaContracts.BusinessLogicsContracts { public interface IComponentLogic { diff --git a/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IOrderLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs similarity index 63% rename from BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IOrderLogic.cs rename to Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs index 6fb9045..fda864a 100644 --- a/BankExecutor/BankExecutorContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -1,8 +1,8 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.ViewModels; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; -namespace BankExecutorContracts.BusinessLogicsContracts +namespace PizzeriaContracts.BusinessLogicsContracts { public interface IOrderLogic { diff --git a/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs new file mode 100644 index 0000000..5ab632a --- /dev/null +++ b/Pizzeria/PizzeriaContracts/BusinessLogicsContracts/IPizzaLogic.cs @@ -0,0 +1,15 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaContracts.BusinessLogicsContracts +{ + public interface IPizzaLogic + { + List? ReadList(PizzaSearchModel? model); + PizzaViewModel? ReadElement(PizzaSearchModel model); + bool Create(PizzaBindingModel model); + bool Update(PizzaBindingModel model); + bool Delete(PizzaBindingModel model); + } +} diff --git a/BankExecutor/BankExecutorContracts/BankExecutorContracts.csproj b/Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj similarity index 61% rename from BankExecutor/BankExecutorContracts/BankExecutorContracts.csproj rename to Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj index c232316..84e1e90 100644 --- a/BankExecutor/BankExecutorContracts/BankExecutorContracts.csproj +++ b/Pizzeria/PizzeriaContracts/PizzeriaContracts.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -7,7 +7,7 @@ - + diff --git a/BankExecutor/BankExecutorContracts/SearchModels/ComponentSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs similarity index 74% rename from BankExecutor/BankExecutorContracts/SearchModels/ComponentSearchModel.cs rename to Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs index 43ccea4..358e3f4 100644 --- a/BankExecutor/BankExecutorContracts/SearchModels/ComponentSearchModel.cs +++ b/Pizzeria/PizzeriaContracts/SearchModels/ComponentSearchModel.cs @@ -1,4 +1,4 @@ -namespace BankExecutorContracts.SearchModels +namespace PizzeriaContracts.SearchModels { public class ComponentSearchModel { diff --git a/BankExecutor/BankExecutorContracts/SearchModels/OrderSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs similarity index 64% rename from BankExecutor/BankExecutorContracts/SearchModels/OrderSearchModel.cs rename to Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs index 858f1be..000683a 100644 --- a/BankExecutor/BankExecutorContracts/SearchModels/OrderSearchModel.cs +++ b/Pizzeria/PizzeriaContracts/SearchModels/OrderSearchModel.cs @@ -1,4 +1,4 @@ -namespace BankExecutorContracts.SearchModels +namespace PizzeriaContracts.SearchModels { public class OrderSearchModel { diff --git a/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs b/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs new file mode 100644 index 0000000..86ebea7 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/SearchModels/PizzaSearchModel.cs @@ -0,0 +1,8 @@ +namespace PizzeriaContracts.SearchModels +{ + public class PizzaSearchModel + { + public int? Id { get; set; } + public string? PizzaName { get; set; } + } +} diff --git a/BankExecutor/BankExecutorContracts/StoragesContracts/IComponentStorage.cs b/Pizzeria/PizzeriaContracts/StoragesContracts/IComponentStorage.cs similarity index 71% rename from BankExecutor/BankExecutorContracts/StoragesContracts/IComponentStorage.cs rename to Pizzeria/PizzeriaContracts/StoragesContracts/IComponentStorage.cs index 771fbac..dc94813 100644 --- a/BankExecutor/BankExecutorContracts/StoragesContracts/IComponentStorage.cs +++ b/Pizzeria/PizzeriaContracts/StoragesContracts/IComponentStorage.cs @@ -1,8 +1,8 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.ViewModels; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; -namespace BankExecutorContracts.StoragesContracts +namespace PizzeriaContracts.StoragesContracts { public interface IComponentStorage { diff --git a/BankExecutor/BankExecutorContracts/StoragesContracts/IOrderStorage.cs b/Pizzeria/PizzeriaContracts/StoragesContracts/IOrderStorage.cs similarity index 69% rename from BankExecutor/BankExecutorContracts/StoragesContracts/IOrderStorage.cs rename to Pizzeria/PizzeriaContracts/StoragesContracts/IOrderStorage.cs index 9204bc3..155f894 100644 --- a/BankExecutor/BankExecutorContracts/StoragesContracts/IOrderStorage.cs +++ b/Pizzeria/PizzeriaContracts/StoragesContracts/IOrderStorage.cs @@ -1,9 +1,9 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.ViewModels; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; -namespace BankExecutorContracts.StoragesContracts +namespace PizzeriaContracts.StoragesContracts { public interface IOrderStorage { diff --git a/Pizzeria/PizzeriaContracts/StoragesContracts/IPizzaStorage.cs b/Pizzeria/PizzeriaContracts/StoragesContracts/IPizzaStorage.cs new file mode 100644 index 0000000..b17907c --- /dev/null +++ b/Pizzeria/PizzeriaContracts/StoragesContracts/IPizzaStorage.cs @@ -0,0 +1,16 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.ViewModels; + +namespace PizzeriaContracts.StoragesContracts +{ + public interface IPizzaStorage + { + List GetFullList(); + List GetFilteredList(PizzaSearchModel model); + PizzaViewModel? GetElement(PizzaSearchModel model); + PizzaViewModel? Insert(PizzaBindingModel model); + PizzaViewModel? Update(PizzaBindingModel model); + PizzaViewModel? Delete(PizzaBindingModel model); + } +} diff --git a/BankExecutor/BankExecutorContracts/ViewModels/ComponentViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs similarity index 65% rename from BankExecutor/BankExecutorContracts/ViewModels/ComponentViewModel.cs rename to Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs index b05576b..1844231 100644 --- a/BankExecutor/BankExecutorContracts/ViewModels/ComponentViewModel.cs +++ b/Pizzeria/PizzeriaContracts/ViewModels/ComponentViewModel.cs @@ -1,12 +1,12 @@ -using BankExecutorDataModels.Models; +using PizzeriaDataModels.Models; using System.ComponentModel; -namespace BankExecutorContracts.ViewModels +namespace PizzeriaContracts.ViewModels { public class ComponentViewModel : IComponentModel { public int Id { get; set; } - [DisplayName("Название компонента")] + [DisplayName("Название ингредиента")] public string ComponentName { get; set; } = string.Empty; [DisplayName("Цена")] public double Cost { get; set; } diff --git a/BankExecutor/BankExecutorContracts/ViewModels/OrderViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs similarity index 71% rename from BankExecutor/BankExecutorContracts/ViewModels/OrderViewModel.cs rename to Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs index e161c82..ebef822 100644 --- a/BankExecutor/BankExecutorContracts/ViewModels/OrderViewModel.cs +++ b/Pizzeria/PizzeriaContracts/ViewModels/OrderViewModel.cs @@ -1,18 +1,18 @@ -using BankExecutorDataModels.Enums; -using BankExecutorDataModels.Models; +using PizzeriaDataModels.Enums; +using PizzeriaDataModels.Models; using System.ComponentModel; -namespace BankExecutorContracts.ViewModels +namespace PizzeriaContracts.ViewModels { public class OrderViewModel : IOrderModel { [DisplayName("Номер")] public int Id { get; set; } - public int ProductId { get; set; } + public int PizzaId { get; set; } - [DisplayName("Изделие")] - public string ProductName { get; set; } = string.Empty; + [DisplayName("Пицца")] + public string PizzaName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } diff --git a/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs b/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs new file mode 100644 index 0000000..f7e8984 --- /dev/null +++ b/Pizzeria/PizzeriaContracts/ViewModels/PizzaViewModel.cs @@ -0,0 +1,15 @@ +using PizzeriaDataModels.Models; +using System.ComponentModel; + +namespace PizzeriaContracts.ViewModels +{ + public class PizzaViewModel : IPizzaModel + { + public int Id { get; set; } + [DisplayName("Название пиццы")] + public string PizzaName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary PizzaComponents { get;set;} = new(); + } +} diff --git a/BankExecutor/AbstractBankDataModels/Enums/OrderStatus.cs b/Pizzeria/PizzeriaDataModels/Enums/OrderStatus.cs similarity index 88% rename from BankExecutor/AbstractBankDataModels/Enums/OrderStatus.cs rename to Pizzeria/PizzeriaDataModels/Enums/OrderStatus.cs index 4cdc953..6c6a4fc 100644 --- a/BankExecutor/AbstractBankDataModels/Enums/OrderStatus.cs +++ b/Pizzeria/PizzeriaDataModels/Enums/OrderStatus.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BankExecutorDataModels.Enums +namespace PizzeriaDataModels.Enums { public enum OrderStatus { diff --git a/BankExecutor/AbstractBankDataModels/IId.cs b/Pizzeria/PizzeriaDataModels/IId.cs similarity index 84% rename from BankExecutor/AbstractBankDataModels/IId.cs rename to Pizzeria/PizzeriaDataModels/IId.cs index d98b105..f7e3b49 100644 --- a/BankExecutor/AbstractBankDataModels/IId.cs +++ b/Pizzeria/PizzeriaDataModels/IId.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BankExecutorDataModels +namespace PizzeriaDataModels { public interface IId { diff --git a/BankExecutor/AbstractBankDataModels/Models/IComponentModel.cs b/Pizzeria/PizzeriaDataModels/Models/IComponentModel.cs similarity index 86% rename from BankExecutor/AbstractBankDataModels/Models/IComponentModel.cs rename to Pizzeria/PizzeriaDataModels/Models/IComponentModel.cs index e9a877c..78f94dd 100644 --- a/BankExecutor/AbstractBankDataModels/Models/IComponentModel.cs +++ b/Pizzeria/PizzeriaDataModels/Models/IComponentModel.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BankExecutorDataModels.Models +namespace PizzeriaDataModels.Models { public interface IComponentModel : IId { diff --git a/BankExecutor/AbstractBankDataModels/Models/IOrderModel.cs b/Pizzeria/PizzeriaDataModels/Models/IOrderModel.cs similarity index 75% rename from BankExecutor/AbstractBankDataModels/Models/IOrderModel.cs rename to Pizzeria/PizzeriaDataModels/Models/IOrderModel.cs index 8cace82..ecab3d7 100644 --- a/BankExecutor/AbstractBankDataModels/Models/IOrderModel.cs +++ b/Pizzeria/PizzeriaDataModels/Models/IOrderModel.cs @@ -1,15 +1,15 @@ -using BankExecutorDataModels.Enums; +using PizzeriaDataModels.Enums; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BankExecutorDataModels.Models +namespace PizzeriaDataModels.Models { public interface IOrderModel : IId { - int ProductId { get; } + int PizzaId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/Pizzeria/PizzeriaDataModels/Models/IPizzaModel.cs b/Pizzeria/PizzeriaDataModels/Models/IPizzaModel.cs new file mode 100644 index 0000000..8ab981e --- /dev/null +++ b/Pizzeria/PizzeriaDataModels/Models/IPizzaModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PizzeriaDataModels.Models +{ + public interface IPizzaModel : IId + { + string PizzaName { get; } + double Price { get; } + Dictionary PizzaComponents { get; } + } +} diff --git a/BankExecutor/AbstractBankDataModels/BankExecutorDataModels.csproj b/Pizzeria/PizzeriaDataModels/PizzeriaDataModels.csproj similarity index 100% rename from BankExecutor/AbstractBankDataModels/BankExecutorDataModels.csproj rename to Pizzeria/PizzeriaDataModels/PizzeriaDataModels.csproj diff --git a/BankExecutor/BankExecutorListImplement/DataListSingleton.cs b/Pizzeria/PizzeriaListImplement/DataListSingleton.cs similarity index 76% rename from BankExecutor/BankExecutorListImplement/DataListSingleton.cs rename to Pizzeria/PizzeriaListImplement/DataListSingleton.cs index 3f0b886..5e82c45 100644 --- a/BankExecutor/BankExecutorListImplement/DataListSingleton.cs +++ b/Pizzeria/PizzeriaListImplement/DataListSingleton.cs @@ -1,18 +1,18 @@ -using BankExecutorListImplement.Models; +using PizzeriaListImplement.Models; -namespace BankExecutorListImplement +namespace PizzeriaListImplement { public class DataListSingleton { private static DataListSingleton? _instance; public List Components { get; set; } public List Orders { get; set; } - public List Products { get; set; } + public List Pizzas { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); - Products = new List(); + Pizzas = new List(); } public static DataListSingleton GetInstance() { diff --git a/BankExecutor/BankExecutorListImplement/Implements/ComponentStorage.cs b/Pizzeria/PizzeriaListImplement/Implements/ComponentStorage.cs similarity index 92% rename from BankExecutor/BankExecutorListImplement/Implements/ComponentStorage.cs rename to Pizzeria/PizzeriaListImplement/Implements/ComponentStorage.cs index da09f1e..9bc59c8 100644 --- a/BankExecutor/BankExecutorListImplement/Implements/ComponentStorage.cs +++ b/Pizzeria/PizzeriaListImplement/Implements/ComponentStorage.cs @@ -1,10 +1,10 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.StoragesContracts; -using BankExecutorContracts.ViewModels; -using BankExecutorListImplement.Models; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.StoragesContracts; +using PizzeriaContracts.ViewModels; +using PizzeriaListImplement.Models; -namespace BankExecutorListImplement.Implements +namespace PizzeriaListImplement.Implements { public class ComponentStorage : IComponentStorage { diff --git a/BankExecutor/BankExecutorListImplement/Implements/OrderStorage.cs b/Pizzeria/PizzeriaListImplement/Implements/OrderStorage.cs similarity index 75% rename from BankExecutor/BankExecutorListImplement/Implements/OrderStorage.cs rename to Pizzeria/PizzeriaListImplement/Implements/OrderStorage.cs index a1c4992..6bf79c1 100644 --- a/BankExecutor/BankExecutorListImplement/Implements/OrderStorage.cs +++ b/Pizzeria/PizzeriaListImplement/Implements/OrderStorage.cs @@ -1,10 +1,10 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.SearchModels; -using BankExecutorContracts.StoragesContracts; -using BankExecutorContracts.ViewModels; -using BankExecutorListImplement.Models; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.StoragesContracts; +using PizzeriaContracts.ViewModels; +using PizzeriaListImplement.Models; -namespace BankExecutorListImplement.Implements +namespace PizzeriaListImplement.Implements { public class OrderStorage : IOrderStorage { @@ -17,7 +17,7 @@ namespace BankExecutorListImplement.Implements var result = new List(); foreach (var order in _source.Orders) { - result.Add(AttachProductName(order.GetViewModel)); + result.Add(AttachPizzaName(order.GetViewModel)); } return result; } @@ -33,7 +33,7 @@ namespace BankExecutorListImplement.Implements { if (order.Id == model.Id) { - result.Add(AttachProductName(order.GetViewModel)); + result.Add(AttachPizzaName(order.GetViewModel)); } } return result; @@ -49,7 +49,7 @@ namespace BankExecutorListImplement.Implements { if (model.Id.HasValue && order.Id == model.Id) { - return AttachProductName(order.GetViewModel); + return AttachPizzaName(order.GetViewModel); } } return null; @@ -71,7 +71,7 @@ namespace BankExecutorListImplement.Implements return null; } _source.Orders.Add(newOrder); - return AttachProductName(newOrder.GetViewModel); + return AttachPizzaName(newOrder.GetViewModel); } public OrderViewModel? Update(OrderBindingModel model) { @@ -80,7 +80,7 @@ namespace BankExecutorListImplement.Implements if (order.Id == model.Id) { order.Update(model); - return AttachProductName(order.GetViewModel); + return AttachPizzaName(order.GetViewModel); } } return null; @@ -93,18 +93,18 @@ namespace BankExecutorListImplement.Implements { var element = _source.Orders[i]; _source.Orders.RemoveAt(i); - return AttachProductName(element.GetViewModel); + return AttachPizzaName(element.GetViewModel); } } return null; } - private OrderViewModel AttachProductName(OrderViewModel model) + private OrderViewModel AttachPizzaName(OrderViewModel model) { - foreach (var product in _source.Products) + foreach (var pizza in _source.Pizzas) { - if (product.Id == model.ProductId) + if (pizza.Id == model.PizzaId) { - model.ProductName = product.ProductName; + model.PizzaName = pizza.PizzaName; return model; } } diff --git a/Pizzeria/PizzeriaListImplement/Implements/PizzaStorage.cs b/Pizzeria/PizzeriaListImplement/Implements/PizzaStorage.cs new file mode 100644 index 0000000..9837eae --- /dev/null +++ b/Pizzeria/PizzeriaListImplement/Implements/PizzaStorage.cs @@ -0,0 +1,101 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.SearchModels; +using PizzeriaContracts.StoragesContracts; +using PizzeriaContracts.ViewModels; +using PizzeriaListImplement.Models; + +namespace PizzeriaListImplement.Implements +{ + public class PizzaStorage : IPizzaStorage + { + private readonly DataListSingleton _source; + public PizzaStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var pizzas in _source.Pizzas) + { + result.Add(pizzas.GetViewModel); + } + return result; + } + public List GetFilteredList(PizzaSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.PizzaName)) + { + return result; + } + foreach (var pizzas in _source.Pizzas) + { + if (pizzas.PizzaName.Contains(model.PizzaName)) + { + result.Add(pizzas.GetViewModel); + } + } + return result; + } + public PizzaViewModel? GetElement(PizzaSearchModel model) + { + if (string.IsNullOrEmpty(model.PizzaName) && !model.Id.HasValue) + { + return null; + } + foreach (var pizzas in _source.Pizzas) + { + if ((!string.IsNullOrEmpty(model.PizzaName) && pizzas.PizzaName == model.PizzaName) || + (model.Id.HasValue && pizzas.Id == model.Id)) + { + return pizzas.GetViewModel; + } + } + return null; + } + public PizzaViewModel? Insert(PizzaBindingModel model) + { + model.Id = 1; + foreach (var pizzas in _source.Pizzas) + { + if (model.Id <= pizzas.Id) + { + model.Id = pizzas.Id + 1; + } + } + var newPizzas = Pizza.Create(model); + if (newPizzas == null) + { + return null; + } + _source.Pizzas.Add(newPizzas); + return newPizzas.GetViewModel; + } + public PizzaViewModel? Update(PizzaBindingModel model) + { + foreach (var pizzas in _source.Pizzas) + { + if (pizzas.Id == model.Id) + { + pizzas.Update(model); + return pizzas.GetViewModel; + } + } + return null; + } + public PizzaViewModel? Delete(PizzaBindingModel model) + { + for (int i = 0; i < _source.Pizzas.Count; ++i) + { + if (_source.Pizzas[i].Id == model.Id) + { + var element = _source.Pizzas[i]; + _source.Pizzas.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/BankExecutor/BankExecutorListImplement/Models/Component.cs b/Pizzeria/PizzeriaListImplement/Models/Component.cs similarity index 85% rename from BankExecutor/BankExecutorListImplement/Models/Component.cs rename to Pizzeria/PizzeriaListImplement/Models/Component.cs index b801f43..d175246 100644 --- a/BankExecutor/BankExecutorListImplement/Models/Component.cs +++ b/Pizzeria/PizzeriaListImplement/Models/Component.cs @@ -1,8 +1,8 @@ -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.ViewModels; -using BankExecutorDataModels.Models; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.ViewModels; +using PizzeriaDataModels.Models; -namespace BankExecutorListImplement.Models +namespace PizzeriaListImplement.Models { public class Component : IComponentModel { diff --git a/BankExecutor/BankExecutorListImplement/Models/Order.cs b/Pizzeria/PizzeriaListImplement/Models/Order.cs similarity index 63% rename from BankExecutor/BankExecutorListImplement/Models/Order.cs rename to Pizzeria/PizzeriaListImplement/Models/Order.cs index 2f7a44c..216ad30 100644 --- a/BankExecutor/BankExecutorListImplement/Models/Order.cs +++ b/Pizzeria/PizzeriaListImplement/Models/Order.cs @@ -1,14 +1,14 @@ -using BankExecutorDataModels.Enums; -using BankExecutorDataModels.Models; -using BankExecutorContracts.BindingModels; -using BankExecutorContracts.ViewModels; +using PizzeriaDataModels.Enums; +using PizzeriaDataModels.Models; +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.ViewModels; -namespace BankExecutorListImplement.Models +namespace PizzeriaListImplement.Models { public class Order : IOrderModel { public int Id { get; private set; } - public int ProductId { get; private set; } + public int PizzaId { get; private set; } public int Count { get; private set; } public double Sum { get; private set; } public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; @@ -23,7 +23,7 @@ namespace BankExecutorListImplement.Models return new Order() { Id = model.Id, - ProductId = model.ProductId, + PizzaId = model.PizzaId, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -37,21 +37,16 @@ namespace BankExecutorListImplement.Models { return; } - ProductId= model.ProductId; - Count= model.Count; - Sum= model.Sum; - Status= model.Status; - DateCreate= model.DateCreate; - DateImplement= model.DateImplement; + Status = model.Status; } public OrderViewModel GetViewModel => new() { Id = Id, - ProductId = ProductId, - Count= Count, - Sum= Sum, - Status= Status, - DateCreate= DateCreate, + PizzaId = PizzaId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, DateImplement = DateImplement, }; } diff --git a/Pizzeria/PizzeriaListImplement/Models/Pizza.cs b/Pizzeria/PizzeriaListImplement/Models/Pizza.cs new file mode 100644 index 0000000..1e3107f --- /dev/null +++ b/Pizzeria/PizzeriaListImplement/Models/Pizza.cs @@ -0,0 +1,45 @@ +using PizzeriaContracts.BindingModels; +using PizzeriaContracts.ViewModels; +using PizzeriaDataModels.Models; + +namespace PizzeriaListImplement.Models +{ + public class Pizza : IPizzaModel + { + public int Id { get; private set; } + public string PizzaName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary PizzaComponents { get; private set;} = new Dictionary(); + public static Pizza? Create(PizzaBindingModel? model) + { + if (model == null) + { + return null; + } + return new Pizza() + { + Id = model.Id, + PizzaName = model.PizzaName, + Price = model.Price, + PizzaComponents = model.PizzaComponents, + }; + } + public void Update(PizzaBindingModel? model) + { + if (model == null) + { + return; + } + PizzaName = model.PizzaName; + Price = model.Price; + PizzaComponents = model.PizzaComponents; + } + public PizzaViewModel GetViewModel => new() + { + Id = Id, + PizzaName = PizzaName, + Price = Price, + PizzaComponents = PizzaComponents + }; + } +} diff --git a/BankExecutor/BankExecutorListImplement/BankExecutorListImplement.csproj b/Pizzeria/PizzeriaListImplement/PizzeriaListImplement.csproj similarity index 56% rename from BankExecutor/BankExecutorListImplement/BankExecutorListImplement.csproj rename to Pizzeria/PizzeriaListImplement/PizzeriaListImplement.csproj index bfbea80..7fca413 100644 --- a/BankExecutor/BankExecutorListImplement/BankExecutorListImplement.csproj +++ b/Pizzeria/PizzeriaListImplement/PizzeriaListImplement.csproj @@ -7,8 +7,8 @@ - - + +