From 3b18db1e8d358e22857b00782048b661902e66f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sat, 28 Jan 2023 13:08:59 +0400 Subject: [PATCH 01/12] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D0=B8=20DataModels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FoodOrders/FoodOrders.sln | 8 +++++++- FoodOrders/FoodOrdersDataModels/Class1.cs | 7 +++++++ .../FoodOrdersDataModels/FoodOrdersDataModels.csproj | 9 +++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 FoodOrders/FoodOrdersDataModels/Class1.cs create mode 100644 FoodOrders/FoodOrdersDataModels/FoodOrdersDataModels.csproj diff --git a/FoodOrders/FoodOrders.sln b/FoodOrders/FoodOrders.sln index 93d863f..5298b56 100644 --- a/FoodOrders/FoodOrders.sln +++ b/FoodOrders/FoodOrders.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32819.101 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrders", "FoodOrders\FoodOrders.csproj", "{5EBC4A03-F86E-493B-9BAF-E75FED9389FC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrders", "FoodOrders\FoodOrders.csproj", "{5EBC4A03-F86E-493B-9BAF-E75FED9389FC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrdersDataModels", "FoodOrdersDataModels\FoodOrdersDataModels.csproj", "{8B4020EF-5761-489C-8958-9B37F4D7FECB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +17,10 @@ Global {5EBC4A03-F86E-493B-9BAF-E75FED9389FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {5EBC4A03-F86E-493B-9BAF-E75FED9389FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {5EBC4A03-F86E-493B-9BAF-E75FED9389FC}.Release|Any CPU.Build.0 = Release|Any CPU + {8B4020EF-5761-489C-8958-9B37F4D7FECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8B4020EF-5761-489C-8958-9B37F4D7FECB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8B4020EF-5761-489C-8958-9B37F4D7FECB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8B4020EF-5761-489C-8958-9B37F4D7FECB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FoodOrders/FoodOrdersDataModels/Class1.cs b/FoodOrders/FoodOrdersDataModels/Class1.cs new file mode 100644 index 0000000..fdd344c --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/Class1.cs @@ -0,0 +1,7 @@ +namespace FoodOrdersDataModels +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersDataModels/FoodOrdersDataModels.csproj b/FoodOrders/FoodOrdersDataModels/FoodOrdersDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/FoodOrdersDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + -- 2.25.1 From 2c830ba99529760ff9048cca39f00529eb771420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sat, 28 Jan 2023 13:14:30 +0400 Subject: [PATCH 02/12] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE?= =?UTF-8?q?=D1=82=D0=B5=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FoodOrders/FoodOrdersDataModels/Class1.cs | 7 ------- FoodOrders/FoodOrdersDataModels/IComponentModel.cs | 9 +++++++++ FoodOrders/FoodOrdersDataModels/IId.cs | 8 ++++++++ FoodOrders/FoodOrdersDataModels/IOrderModel.cs | 14 ++++++++++++++ FoodOrders/FoodOrdersDataModels/IProductModel.cs | 10 ++++++++++ FoodOrders/FoodOrdersDataModels/OrderStatus.cs | 11 +++++++++++ 6 files changed, 52 insertions(+), 7 deletions(-) delete mode 100644 FoodOrders/FoodOrdersDataModels/Class1.cs create mode 100644 FoodOrders/FoodOrdersDataModels/IComponentModel.cs create mode 100644 FoodOrders/FoodOrdersDataModels/IId.cs create mode 100644 FoodOrders/FoodOrdersDataModels/IOrderModel.cs create mode 100644 FoodOrders/FoodOrdersDataModels/IProductModel.cs create mode 100644 FoodOrders/FoodOrdersDataModels/OrderStatus.cs diff --git a/FoodOrders/FoodOrdersDataModels/Class1.cs b/FoodOrders/FoodOrdersDataModels/Class1.cs deleted file mode 100644 index fdd344c..0000000 --- a/FoodOrders/FoodOrdersDataModels/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FoodOrdersDataModels -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersDataModels/IComponentModel.cs b/FoodOrders/FoodOrdersDataModels/IComponentModel.cs new file mode 100644 index 0000000..2e2e443 --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/IComponentModel.cs @@ -0,0 +1,9 @@ + +namespace FoodOrdersDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/FoodOrders/FoodOrdersDataModels/IId.cs b/FoodOrders/FoodOrdersDataModels/IId.cs new file mode 100644 index 0000000..19763e1 --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/IId.cs @@ -0,0 +1,8 @@ + +namespace FoodOrdersDataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/FoodOrders/FoodOrdersDataModels/IOrderModel.cs b/FoodOrders/FoodOrdersDataModels/IOrderModel.cs new file mode 100644 index 0000000..084cb40 --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/IOrderModel.cs @@ -0,0 +1,14 @@ +using FoodOrdersDataModels.Enums; + +namespace FoodOrdersDataModels.Models +{ + public interface IOrderModel : IId + { + int ProductId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} diff --git a/FoodOrders/FoodOrdersDataModels/IProductModel.cs b/FoodOrders/FoodOrdersDataModels/IProductModel.cs new file mode 100644 index 0000000..ba632eb --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/IProductModel.cs @@ -0,0 +1,10 @@ + +namespace FoodOrdersDataModels.Models +{ + public interface IProductModel : IId + { + string ProductName { get; } + double Price { get; } + Dictionary ProductComponents { get; } + } +} diff --git a/FoodOrders/FoodOrdersDataModels/OrderStatus.cs b/FoodOrders/FoodOrdersDataModels/OrderStatus.cs new file mode 100644 index 0000000..1d9b0ed --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/OrderStatus.cs @@ -0,0 +1,11 @@ +namespace FoodOrdersDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} \ No newline at end of file -- 2.25.1 From 6b820fa6c3166fb2eb6bbdfd967bfafc6ae39302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sat, 28 Jan 2023 13:15:28 +0400 Subject: [PATCH 03/12] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D0=B8=20Contracts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FoodOrders/FoodOrders.sln | 6 ++++++ FoodOrders/FoodOrdersContracts/Class1.cs | 7 +++++++ .../FoodOrdersContracts/FoodOrdersContracts.csproj | 9 +++++++++ 3 files changed, 22 insertions(+) create mode 100644 FoodOrders/FoodOrdersContracts/Class1.cs create mode 100644 FoodOrders/FoodOrdersContracts/FoodOrdersContracts.csproj diff --git a/FoodOrders/FoodOrders.sln b/FoodOrders/FoodOrders.sln index 5298b56..99670ee 100644 --- a/FoodOrders/FoodOrders.sln +++ b/FoodOrders/FoodOrders.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrders", "FoodOrders\Fo EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrdersDataModels", "FoodOrdersDataModels\FoodOrdersDataModels.csproj", "{8B4020EF-5761-489C-8958-9B37F4D7FECB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrdersContracts", "FoodOrdersContracts\FoodOrdersContracts.csproj", "{5527E07B-9B94-4735-93FB-49267F0B8038}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {8B4020EF-5761-489C-8958-9B37F4D7FECB}.Debug|Any CPU.Build.0 = Debug|Any CPU {8B4020EF-5761-489C-8958-9B37F4D7FECB}.Release|Any CPU.ActiveCfg = Release|Any CPU {8B4020EF-5761-489C-8958-9B37F4D7FECB}.Release|Any CPU.Build.0 = Release|Any CPU + {5527E07B-9B94-4735-93FB-49267F0B8038}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5527E07B-9B94-4735-93FB-49267F0B8038}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5527E07B-9B94-4735-93FB-49267F0B8038}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5527E07B-9B94-4735-93FB-49267F0B8038}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FoodOrders/FoodOrdersContracts/Class1.cs b/FoodOrders/FoodOrdersContracts/Class1.cs new file mode 100644 index 0000000..c470fb5 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/Class1.cs @@ -0,0 +1,7 @@ +namespace FoodOrdersContracts +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/FoodOrdersContracts.csproj b/FoodOrders/FoodOrdersContracts/FoodOrdersContracts.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/FoodOrdersContracts.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + -- 2.25.1 From b3c210527c0440e71293bcbac400ddb73284c7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Tue, 7 Feb 2023 13:00:02 +0400 Subject: [PATCH 04/12] LabWork01 --- FoodOrders/FoodOrders.sln | 18 +- FoodOrders/FoodOrders/FoodOrders.csproj | 11 - FoodOrders/FoodOrders/FoodOrdersView.csproj | 23 ++ FoodOrders/FoodOrders/Form1.Designer.cs | 39 --- FoodOrders/FoodOrders/Form1.cs | 10 - FoodOrders/FoodOrders/Form1.resx | 120 --------- .../FoodOrders/FormCreateOrder.Designer.cs | 149 +++++++++++ FoodOrders/FoodOrders/FormCreateOrder.cs | 117 +++++++++ FoodOrders/FoodOrders/FormCreateOrder.resx | 60 +++++ FoodOrders/FoodOrders/FormDish.Designer.cs | 123 +++++++++ FoodOrders/FoodOrders/FormDish.cs | 87 +++++++ FoodOrders/FoodOrders/FormDish.resx | 60 +++++ FoodOrders/FoodOrders/FormDishes.Designer.cs | 122 +++++++++ FoodOrders/FoodOrders/FormDishes.cs | 100 +++++++ FoodOrders/FoodOrders/FormDishes.resx | 60 +++++ .../FormListSetOfDishes.Designer.cs | 122 +++++++++ FoodOrders/FoodOrders/FormListSetOfDishes.cs | 105 ++++++++ .../FoodOrders/FormListSetOfDishes.resx | 60 +++++ FoodOrders/FoodOrders/FormMain.Designer.cs | 182 +++++++++++++ FoodOrders/FoodOrders/FormMain.cs | 167 ++++++++++++ FoodOrders/FoodOrders/FormMain.resx | 60 +++++ .../FoodOrders/FormSetOfDishes.Designer.cs | 246 ++++++++++++++++++ FoodOrders/FoodOrders/FormSetOfDishes.cs | 207 +++++++++++++++ FoodOrders/FoodOrders/FormSetOfDishes.resx | 69 +++++ .../FormSetOfDishesComponents.Designer.cs | 123 +++++++++ .../FoodOrders/FormSetOfDishesComponents.cs | 79 ++++++ .../FoodOrders/FormSetOfDishesComponents.resx | 60 +++++ FoodOrders/FoodOrders/Program.cs | 40 ++- .../BusinessLogics/DishLogic.cs | 112 ++++++++ .../BusinessLogics/OrderLogic.cs | 113 ++++++++ .../BusinessLogics/SetOfDishesLogic.cs | 118 +++++++++ .../FoodOrdersBusinessLogic.csproj | 19 ++ .../BindingModels/DishBindingModel.cs | 11 + .../BindingModels/OrderBindingModel.cs | 17 ++ .../BindingModels/SetOfDishesBindingModel.cs | 16 ++ .../BuisnessLogicsContracts/IDishLogic.cs | 15 ++ .../BuisnessLogicsContracts/IOrderLogic.cs | 15 ++ .../ISetOfDishesLogic.cs | 15 ++ FoodOrders/FoodOrdersContracts/Class1.cs | 7 - .../FoodOrdersContracts.csproj | 10 + .../SearchModels/DishSearchModel.cs | 9 + .../SearchModels/OrderSearchModel.cs | 8 + .../SearchModels/SetOfDishesSearchModel.cs | 9 + .../StoragesContracts/IDishStorage.cs | 16 ++ .../StoragesContracts/IOrderStorage.cs | 16 ++ .../StoragesContracts/ISetOfDishesStorage.cs | 16 ++ .../ViewModels/DishViewModel.cs | 13 + .../ViewModels/OrderViewModel.cs | 31 +++ .../ViewModels/SetOfDishesViewModel.cs | 15 ++ .../{IComponentModel.cs => IDishModel.cs} | 4 +- .../FoodOrdersDataModels/IOrderModel.cs | 2 +- .../FoodOrdersDataModels/IProductModel.cs | 10 - .../FoodOrdersDataModels/ISetOfDishesModel.cs | 10 + .../DataListSingleton.cs | 26 ++ .../FoodOrdersListImplement.csproj | 14 + .../Implements/DishStorage.cs | 103 ++++++++ .../Implements/OrderStorage.cs | 108 ++++++++ .../Implements/SetOfDishesStorage.cs | 103 ++++++++ .../Models/Component.cs | 41 +++ .../FoodOrdersListImplement/Models/Order.cs | 64 +++++ .../FoodOrdersListImplement/Models/Product.cs | 49 ++++ 61 files changed, 3550 insertions(+), 204 deletions(-) delete mode 100644 FoodOrders/FoodOrders/FoodOrders.csproj create mode 100644 FoodOrders/FoodOrders/FoodOrdersView.csproj delete mode 100644 FoodOrders/FoodOrders/Form1.Designer.cs delete mode 100644 FoodOrders/FoodOrders/Form1.cs delete mode 100644 FoodOrders/FoodOrders/Form1.resx create mode 100644 FoodOrders/FoodOrders/FormCreateOrder.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormCreateOrder.cs create mode 100644 FoodOrders/FoodOrders/FormCreateOrder.resx create mode 100644 FoodOrders/FoodOrders/FormDish.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormDish.cs create mode 100644 FoodOrders/FoodOrders/FormDish.resx create mode 100644 FoodOrders/FoodOrders/FormDishes.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormDishes.cs create mode 100644 FoodOrders/FoodOrders/FormDishes.resx create mode 100644 FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormListSetOfDishes.cs create mode 100644 FoodOrders/FoodOrders/FormListSetOfDishes.resx create mode 100644 FoodOrders/FoodOrders/FormMain.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormMain.cs create mode 100644 FoodOrders/FoodOrders/FormMain.resx create mode 100644 FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormSetOfDishes.cs create mode 100644 FoodOrders/FoodOrders/FormSetOfDishes.resx create mode 100644 FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormSetOfDishesComponents.cs create mode 100644 FoodOrders/FoodOrders/FormSetOfDishesComponents.resx create mode 100644 FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/DishLogic.cs create mode 100644 FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs create mode 100644 FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/SetOfDishesLogic.cs create mode 100644 FoodOrders/FoodOrdersBusinessLogic/FoodOrdersBusinessLogic.csproj create mode 100644 FoodOrders/FoodOrdersContracts/BindingModels/DishBindingModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/BindingModels/SetOfDishesBindingModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IDishLogic.cs create mode 100644 FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IOrderLogic.cs create mode 100644 FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/ISetOfDishesLogic.cs delete mode 100644 FoodOrders/FoodOrdersContracts/Class1.cs create mode 100644 FoodOrders/FoodOrdersContracts/SearchModels/DishSearchModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/SearchModels/OrderSearchModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/SearchModels/SetOfDishesSearchModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/StoragesContracts/IDishStorage.cs create mode 100644 FoodOrders/FoodOrdersContracts/StoragesContracts/IOrderStorage.cs create mode 100644 FoodOrders/FoodOrdersContracts/StoragesContracts/ISetOfDishesStorage.cs create mode 100644 FoodOrders/FoodOrdersContracts/ViewModels/DishViewModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/ViewModels/SetOfDishesViewModel.cs rename FoodOrders/FoodOrdersDataModels/{IComponentModel.cs => IDishModel.cs} (51%) delete mode 100644 FoodOrders/FoodOrdersDataModels/IProductModel.cs create mode 100644 FoodOrders/FoodOrdersDataModels/ISetOfDishesModel.cs create mode 100644 FoodOrders/FoodOrdersListImplement/DataListSingleton.cs create mode 100644 FoodOrders/FoodOrdersListImplement/FoodOrdersListImplement.csproj create mode 100644 FoodOrders/FoodOrdersListImplement/Implements/DishStorage.cs create mode 100644 FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs create mode 100644 FoodOrders/FoodOrdersListImplement/Implements/SetOfDishesStorage.cs create mode 100644 FoodOrders/FoodOrdersListImplement/Models/Component.cs create mode 100644 FoodOrders/FoodOrdersListImplement/Models/Order.cs create mode 100644 FoodOrders/FoodOrdersListImplement/Models/Product.cs diff --git a/FoodOrders/FoodOrders.sln b/FoodOrders/FoodOrders.sln index 99670ee..68f3899 100644 --- a/FoodOrders/FoodOrders.sln +++ b/FoodOrders/FoodOrders.sln @@ -3,11 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32819.101 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrders", "FoodOrders\FoodOrders.csproj", "{5EBC4A03-F86E-493B-9BAF-E75FED9389FC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrdersView", "FoodOrders\FoodOrdersView.csproj", "{5EBC4A03-F86E-493B-9BAF-E75FED9389FC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrdersDataModels", "FoodOrdersDataModels\FoodOrdersDataModels.csproj", "{8B4020EF-5761-489C-8958-9B37F4D7FECB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrdersDataModels", "FoodOrdersDataModels\FoodOrdersDataModels.csproj", "{8B4020EF-5761-489C-8958-9B37F4D7FECB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrdersContracts", "FoodOrdersContracts\FoodOrdersContracts.csproj", "{5527E07B-9B94-4735-93FB-49267F0B8038}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FoodOrdersContracts", "FoodOrdersContracts\FoodOrdersContracts.csproj", "{5527E07B-9B94-4735-93FB-49267F0B8038}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrdersBusinessLogic", "FoodOrdersBusinessLogic\FoodOrdersBusinessLogic.csproj", "{4C44A99E-7D02-4D07-9714-9414423B560E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FoodOrdersListImplement", "FoodOrdersListImplement\FoodOrdersListImplement.csproj", "{A4012AB3-40FB-4FF6-A55A-E593AB80A153}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -27,6 +31,14 @@ Global {5527E07B-9B94-4735-93FB-49267F0B8038}.Debug|Any CPU.Build.0 = Debug|Any CPU {5527E07B-9B94-4735-93FB-49267F0B8038}.Release|Any CPU.ActiveCfg = Release|Any CPU {5527E07B-9B94-4735-93FB-49267F0B8038}.Release|Any CPU.Build.0 = Release|Any CPU + {4C44A99E-7D02-4D07-9714-9414423B560E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C44A99E-7D02-4D07-9714-9414423B560E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C44A99E-7D02-4D07-9714-9414423B560E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C44A99E-7D02-4D07-9714-9414423B560E}.Release|Any CPU.Build.0 = Release|Any CPU + {A4012AB3-40FB-4FF6-A55A-E593AB80A153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4012AB3-40FB-4FF6-A55A-E593AB80A153}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4012AB3-40FB-4FF6-A55A-E593AB80A153}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4012AB3-40FB-4FF6-A55A-E593AB80A153}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FoodOrders/FoodOrders/FoodOrders.csproj b/FoodOrders/FoodOrders/FoodOrders.csproj deleted file mode 100644 index b57c89e..0000000 --- a/FoodOrders/FoodOrders/FoodOrders.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - enable - - - \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FoodOrdersView.csproj b/FoodOrders/FoodOrders/FoodOrdersView.csproj new file mode 100644 index 0000000..d32249f --- /dev/null +++ b/FoodOrders/FoodOrders/FoodOrdersView.csproj @@ -0,0 +1,23 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FoodOrders/FoodOrders/Form1.Designer.cs b/FoodOrders/FoodOrders/Form1.Designer.cs deleted file mode 100644 index 9142cf3..0000000 --- a/FoodOrders/FoodOrders/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace FoodOrders -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/Form1.cs b/FoodOrders/FoodOrders/Form1.cs deleted file mode 100644 index 387555b..0000000 --- a/FoodOrders/FoodOrders/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace FoodOrders -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/Form1.resx b/FoodOrders/FoodOrders/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FoodOrders/FoodOrders/Form1.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/FoodOrders/FoodOrders/FormCreateOrder.Designer.cs b/FoodOrders/FoodOrders/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..96b3e0f --- /dev/null +++ b/FoodOrders/FoodOrders/FormCreateOrder.Designer.cs @@ -0,0 +1,149 @@ +namespace FoodOrdersView +{ + partial class FormCreateOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.comboBoxSetOfDishes = new System.Windows.Forms.ComboBox(); + this.labelSum = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.labelName = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(241, 90); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(82, 22); + this.buttonCancel.TabIndex = 15; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(153, 90); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(82, 22); + this.buttonSave.TabIndex = 14; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // textBoxSum + // + this.textBoxSum.Location = new System.Drawing.Point(93, 63); + this.textBoxSum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.Size = new System.Drawing.Size(230, 23); + this.textBoxSum.TabIndex = 13; + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(93, 36); + this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(230, 23); + this.textBoxCount.TabIndex = 12; + this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); + // + // comboBoxSetOfDishes + // + this.comboBoxSetOfDishes.FormattingEnabled = true; + this.comboBoxSetOfDishes.Location = new System.Drawing.Point(93, 9); + this.comboBoxSetOfDishes.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxSetOfDishes.Name = "comboBoxSetOfDishes"; + this.comboBoxSetOfDishes.Size = new System.Drawing.Size(230, 23); + this.comboBoxSetOfDishes.TabIndex = 11; + this.comboBoxSetOfDishes.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSetOfDishes_SelectedIndexChanged); + // + // labelSum + // + this.labelSum.AutoSize = true; + this.labelSum.Location = new System.Drawing.Point(12, 63); + this.labelSum.Name = "labelSum"; + this.labelSum.Size = new System.Drawing.Size(48, 15); + this.labelSum.TabIndex = 10; + this.labelSum.Text = "Сумма:"; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(12, 36); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(75, 15); + this.labelCount.TabIndex = 9; + this.labelCount.Text = "Количество:"; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(12, 9); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(42, 15); + this.labelName.TabIndex = 8; + this.labelName.Text = "Набор блюд:"; + // + // FormCreateOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(343, 128); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxSetOfDishes); + this.Controls.Add(this.labelSum); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelName); + this.Name = "FormCreateOrder"; + this.Text = "Заказ"; + this.Load += new System.EventHandler(this.FormCreateOrder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxSum; + private TextBox textBoxCount; + private ComboBox comboBoxSetOfDishes; + private Label labelSum; + private Label labelCount; + private Label labelName; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormCreateOrder.cs b/FoodOrders/FoodOrders/FormCreateOrder.cs new file mode 100644 index 0000000..2c1ca37 --- /dev/null +++ b/FoodOrders/FoodOrders/FormCreateOrder.cs @@ -0,0 +1,117 @@ +using Microsoft.Extensions.Logging; +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.SearchModels; + +namespace FoodOrdersView +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly ISetOfDishesLogic _logicS; + private readonly IOrderLogic _logicO; + public FormCreateOrder(ILogger logger, ISetOfDishesLogic logicS, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicS = logicS; + _logicO = logicO; + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка Набор блюд для заказа"); + try + { + var list = _logicS.ReadList(null); + if (list != null) + { + comboBoxSetOfDishes.DisplayMember = "SetOfDishesName"; + comboBoxSetOfDishes.ValueMember = "Id"; + comboBoxSetOfDishes.DataSource = list; + comboBoxSetOfDishes.SelectedItem = null; + } + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка Набор блюд"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void CalcSum() + { + if (comboBoxSetOfDishes.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxSetOfDishes.SelectedValue); + var product = _logicS.ReadElement(new SetOfDishesearchModel + { + Id = id + }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void TextBoxCount_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void ComboBoxSetOfDishes_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле 'Количество'", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxSetOfDishes.SelectedValue == null) + { + MessageBox.Show("Выберите Набор блюд", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + SetOfDishesId = Convert.ToInt32(comboBoxSetOfDishes.SelectedValue), + SetOfDishesName = comboBoxSetOfDishes.Text, + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.Text) + }); + if (!operationResult) + { + throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", + MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/FoodOrders/FoodOrders/FormCreateOrder.resx b/FoodOrders/FoodOrders/FormCreateOrder.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FoodOrders/FoodOrders/FormCreateOrder.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/FoodOrders/FoodOrders/FormDish.Designer.cs b/FoodOrders/FoodOrders/FormDish.Designer.cs new file mode 100644 index 0000000..eda2ab6 --- /dev/null +++ b/FoodOrders/FoodOrders/FormDish.Designer.cs @@ -0,0 +1,123 @@ +namespace FoodOrdersView +{ + partial class FormDish + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer Dishes = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (Dishes != null)) + { + Dishes.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.textBoxCost = new System.Windows.Forms.TextBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelPrice = new System.Windows.Forms.Label(); + this.labelBlankName = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(200, 73); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(82, 22); + this.buttonCancel.TabIndex = 11; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(112, 73); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(82, 22); + this.buttonSave.TabIndex = 10; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // textBoxCost + // + this.textBoxCost.Location = new System.Drawing.Point(111, 38); + this.textBoxCost.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxCost.Name = "textBoxCost"; + this.textBoxCost.Size = new System.Drawing.Size(183, 23); + this.textBoxCost.TabIndex = 9; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(111, 11); + this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(329, 23); + this.textBoxName.TabIndex = 8; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(12, 37); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(38, 15); + this.labelPrice.TabIndex = 7; + this.labelPrice.Text = "Цена:"; + // + // labelBlankName + // + this.labelBlankName.AutoSize = true; + this.labelBlankName.Location = new System.Drawing.Point(12, 14); + this.labelBlankName.Name = "labelBlankName"; + this.labelBlankName.Size = new System.Drawing.Size(62, 15); + this.labelBlankName.TabIndex = 6; + this.labelBlankName.Text = "Название:"; + // + // FormDish + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(448, 106); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxCost); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelBlankName); + this.Name = "FormDish"; + this.Text = "Блюдо"; + this.Load += new System.EventHandler(this.FormDish_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxCost; + private TextBox textBoxName; + private Label labelPrice; + private Label labelBlankName; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormDish.cs b/FoodOrders/FoodOrders/FormDish.cs new file mode 100644 index 0000000..806255b --- /dev/null +++ b/FoodOrders/FoodOrders/FormDish.cs @@ -0,0 +1,87 @@ +using Microsoft.Extensions.Logging; +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.BindingModels; + +namespace FoodOrdersView +{ + public partial class FormDish : Form + { + private readonly ILogger _logger; + private readonly IDishLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + + public FormDish(ILogger logger, IDishLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormDish_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение блюда"); + var view = _logic.ReadElement(new DishesearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.DishName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения блюда"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение блюда"); + try + { + var model = new DishBindingModel + { + Id = _id ?? 0, + DishName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения блюда"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + } +} diff --git a/FoodOrders/FoodOrders/FormDish.resx b/FoodOrders/FoodOrders/FormDish.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FoodOrders/FoodOrders/FormDish.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/FoodOrders/FoodOrders/FormDishes.Designer.cs b/FoodOrders/FoodOrders/FormDishes.Designer.cs new file mode 100644 index 0000000..d62400f --- /dev/null +++ b/FoodOrders/FoodOrders/FormDishes.Designer.cs @@ -0,0 +1,122 @@ +namespace FoodOrdersView +{ + partial class FormDishes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer Dishes = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (Dishes != null)) + { + Dishes.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(432, 186); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(130, 22); + this.buttonUpdate.TabIndex = 9; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(432, 160); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(130, 22); + this.buttonDelete.TabIndex = 8; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonEdit + // + this.buttonEdit.Location = new System.Drawing.Point(432, 134); + this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonEdit.Name = "buttonEdit"; + this.buttonEdit.Size = new System.Drawing.Size(130, 22); + this.buttonEdit.TabIndex = 7; + this.buttonEdit.Text = "Изменить"; + this.buttonEdit.UseVisualStyleBackColor = true; + this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(432, 108); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(130, 22); + this.buttonAdd.TabIndex = 6; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.dataGridView.GridColor = System.Drawing.Color.White; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(426, 348); + this.dataGridView.TabIndex = 5; + // + // FormDishes + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(571, 348); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonUpdate); + this.Controls.Add(this.buttonDelete); + this.Controls.Add(this.buttonEdit); + this.Controls.Add(this.buttonAdd); + this.Name = "FormDishes"; + this.Text = "Блюда"; + this.Load += new System.EventHandler(this.FormDishes_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonEdit; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormDishes.cs b/FoodOrders/FoodOrders/FormDishes.cs new file mode 100644 index 0000000..c806bcf --- /dev/null +++ b/FoodOrders/FoodOrders/FormDishes.cs @@ -0,0 +1,100 @@ +using FoodOrders; +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace FoodOrdersView +{ + public partial class FormDishes : Form + { + private readonly ILogger _logger; + private readonly IDishLogic _logic; + public FormDishes(ILogger logger, IDishLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormDishes_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["DishName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка Блюд"); + } + catch (Exception 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(FormDish)); + if (service is FormDish form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDish)); + if (service is FormDish form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление блюда"); + try + { + if (!_logic.Delete(new DishBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления блюда"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/FoodOrders/FoodOrders/FormDishes.resx b/FoodOrders/FoodOrders/FormDishes.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FoodOrders/FoodOrders/FormDishes.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/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs b/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs new file mode 100644 index 0000000..6353298 --- /dev/null +++ b/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs @@ -0,0 +1,122 @@ +namespace FoodOrdersView +{ + partial class FormListSetOfDishes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer Dishes = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (Dishes != null)) + { + Dishes.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + 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.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.dataGridView.GridColor = System.Drawing.Color.White; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(426, 345); + this.dataGridView.TabIndex = 10; + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(432, 183); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(130, 22); + this.buttonUpdate.TabIndex = 14; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(432, 157); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(130, 22); + this.buttonDelete.TabIndex = 13; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click); + // + // buttonEdit + // + this.buttonEdit.Location = new System.Drawing.Point(432, 131); + this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonEdit.Name = "buttonEdit"; + this.buttonEdit.Size = new System.Drawing.Size(130, 22); + this.buttonEdit.TabIndex = 12; + this.buttonEdit.Text = "Изменить"; + this.buttonEdit.UseVisualStyleBackColor = true; + this.buttonEdit.Click += new System.EventHandler(this.ButtonEdit_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(432, 105); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(130, 22); + this.buttonAdd.TabIndex = 11; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // FormListSetOfDishes + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(570, 345); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.buttonUpdate); + this.Controls.Add(this.buttonDelete); + this.Controls.Add(this.buttonEdit); + this.Controls.Add(this.buttonAdd); + this.Name = "FormListSetOfDishes"; + this.Text = "Список набор блюд"; + this.Load += new System.EventHandler(this.FormDocuments_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonEdit; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormListSetOfDishes.cs b/FoodOrders/FoodOrders/FormListSetOfDishes.cs new file mode 100644 index 0000000..cdd61f8 --- /dev/null +++ b/FoodOrders/FoodOrders/FormListSetOfDishes.cs @@ -0,0 +1,105 @@ +using FoodOrders; +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace FoodOrdersView +{ + public partial class FormListSetOfDishes : Form + { + private readonly ILogger _logger; + private readonly IDishLogic _logic; + public FormListSetOfDishes(ILogger logger, IDishLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormDocuments_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ProdyctName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["SetOfDishesDishes"].Visible = false; + } + _logger.LogInformation("Загрузка набор блюд"); + } + catch (Exception 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(FormSetOfDishes)); + if (service is FormSetOfDishes form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonEdit_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishes)); + if (service is FormSetOfDishes form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление набор блюд"); + try + { + if (!_logic.Delete(new DishBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления набор блюд"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonUpdate_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/FoodOrders/FoodOrders/FormListSetOfDishes.resx b/FoodOrders/FoodOrders/FormListSetOfDishes.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FoodOrders/FoodOrders/FormListSetOfDishes.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/FoodOrders/FoodOrders/FormMain.Designer.cs b/FoodOrders/FoodOrders/FormMain.Designer.cs new file mode 100644 index 0000000..6a6905d --- /dev/null +++ b/FoodOrders/FoodOrders/FormMain.Designer.cs @@ -0,0 +1,182 @@ +namespace FoodOrdersView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer Dishes = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (Dishes != null)) + { + Dishes.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.menuStrip = 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.buttonUpdate = new System.Windows.Forms.Button(); + this.buttonSetToFinish = new System.Windows.Forms.Button(); + this.buttonSetToDone = new System.Windows.Forms.Button(); + this.buttonSetToWork = new System.Windows.Forms.Button(); + this.buttonCreateOrder = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // menuStrip + // + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.справочникиToolStripMenuItem}); + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(975, 24); + this.menuStrip.TabIndex = 0; + this.menuStrip.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.БлюдаToolStripMenuItem, + this.наборблюдToolStripMenuItem}); + this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.справочникиToolStripMenuItem.Text = "Справочники"; + // + // БлюдаToolStripMenuItem + // + this.БлюдаToolStripMenuItem.Name = "БлюдаToolStripMenuItem"; + this.БлюдаToolStripMenuItem.Size = new System.Drawing.Size(148, 22); + this.БлюдаToolStripMenuItem.Text = "Блюда"; + this.БлюдаToolStripMenuItem.Click += new System.EventHandler(this.DishesToolStripMenuItem_Click); + // + // набор блюдToolStripMenuItem + // + this.наборблюдToolStripMenuItem.Name = "набор блюдToolStripMenuItem"; + this.наборблюдToolStripMenuItem.Size = new System.Drawing.Size(148, 22); + this.наборблюдToolStripMenuItem.Text = "Набор блюд"; + this.наборблюдToolStripMenuItem.Click += new System.EventHandler(this.SetOfDishesToolStripMenuItem_Click); + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(780, 314); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(170, 58); + this.buttonUpdate.TabIndex = 12; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonSetToFinish + // + this.buttonSetToFinish.Location = new System.Drawing.Point(780, 252); + this.buttonSetToFinish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSetToFinish.Name = "buttonSetToFinish"; + this.buttonSetToFinish.Size = new System.Drawing.Size(170, 58); + this.buttonSetToFinish.TabIndex = 11; + this.buttonSetToFinish.Text = "Заказ выдан"; + this.buttonSetToFinish.UseVisualStyleBackColor = true; + this.buttonSetToFinish.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + // + // buttonSetToDone + // + this.buttonSetToDone.Location = new System.Drawing.Point(780, 190); + this.buttonSetToDone.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSetToDone.Name = "buttonSetToDone"; + this.buttonSetToDone.Size = new System.Drawing.Size(170, 58); + this.buttonSetToDone.TabIndex = 10; + this.buttonSetToDone.Text = "Заказ готов"; + this.buttonSetToDone.UseVisualStyleBackColor = true; + this.buttonSetToDone.Click += new System.EventHandler(this.ButtonOrderReady_Click); + // + // buttonSetToWork + // + this.buttonSetToWork.Location = new System.Drawing.Point(780, 128); + this.buttonSetToWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSetToWork.Name = "buttonSetToWork"; + this.buttonSetToWork.Size = new System.Drawing.Size(170, 58); + this.buttonSetToWork.TabIndex = 9; + this.buttonSetToWork.Text = "Отдать на выполнение"; + this.buttonSetToWork.UseVisualStyleBackColor = true; + this.buttonSetToWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + // + // buttonCreateOrder + // + this.buttonCreateOrder.Location = new System.Drawing.Point(780, 66); + this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCreateOrder.Name = "buttonCreateOrder"; + this.buttonCreateOrder.Size = new System.Drawing.Size(170, 58); + this.buttonCreateOrder.TabIndex = 8; + this.buttonCreateOrder.Text = "Создать заказ"; + this.buttonCreateOrder.UseVisualStyleBackColor = true; + this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.dataGridView.Location = new System.Drawing.Point(0, 24); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(755, 426); + this.dataGridView.TabIndex = 7; + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(975, 450); + this.Controls.Add(this.buttonUpdate); + this.Controls.Add(this.buttonSetToFinish); + this.Controls.Add(this.buttonSetToDone); + this.Controls.Add(this.buttonSetToWork); + this.Controls.Add(this.buttonCreateOrder); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; + this.Name = "FormMain"; + this.Text = "Набор блюд"; + this.Load += new System.EventHandler(this.FormMain_Load); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem БлюдаToolStripMenuItem; + private ToolStripMenuItem наборблюдToolStripMenuItem; + private Button buttonUpdate; + private Button buttonSetToFinish; + private Button buttonSetToDone; + private Button buttonSetToWork; + private Button buttonCreateOrder; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormMain.cs b/FoodOrders/FoodOrders/FormMain.cs new file mode 100644 index 0000000..b5c7653 --- /dev/null +++ b/FoodOrders/FoodOrders/FormMain.cs @@ -0,0 +1,167 @@ +using FoodOrders; +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersDataModels.Enums; +using FoodOrdersView; +using Microsoft.Extensions.Logging; + +namespace FoodOrdersView +{ + public partial class FormMain : Form + { + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["SetOfDishesId"].Visible = false; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void DishesToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDishes)); + if (service is FormDishes form) + { + form.ShowDialog(); + } + } + private void SetOfDishesToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishes)); + if (service is FormSetOfDishes form) + { + form.ShowDialog(); + } + } + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel + { + Id = id, + SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value), + SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + try + { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel + { + Id = id, + SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value), + SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = id, + SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value), + SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(), + Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), + Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), + Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), + DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormMain.resx b/FoodOrders/FoodOrders/FormMain.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FoodOrders/FoodOrders/FormMain.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/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs b/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs new file mode 100644 index 0000000..20c7b13 --- /dev/null +++ b/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs @@ -0,0 +1,246 @@ +namespace FoodOrdersView +{ + partial class FormSetOfDishes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer Dishes = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (Dishes != null)) + { + Dishes.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelPrice = new System.Windows.Forms.Label(); + this.labelName = new System.Windows.Forms.Label(); + this.groupBoxDishes = new System.Windows.Forms.GroupBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = 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(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnDishName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBoxDishes.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(90, 36); + this.textBoxPrice.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(138, 23); + this.textBoxPrice.TabIndex = 7; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(90, 11); + this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(276, 23); + this.textBoxName.TabIndex = 6; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(14, 41); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(70, 15); + this.labelPrice.TabIndex = 5; + this.labelPrice.Text = "Стоимость:"; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(14, 14); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(62, 15); + this.labelName.TabIndex = 4; + this.labelName.Text = "Название:"; + // + // groupBoxDishes + // + this.groupBoxDishes.Controls.Add(this.buttonCancel); + this.groupBoxDishes.Controls.Add(this.buttonSave); + this.groupBoxDishes.Controls.Add(this.buttonUpdate); + this.groupBoxDishes.Controls.Add(this.buttonDelete); + this.groupBoxDishes.Controls.Add(this.buttonEdit); + this.groupBoxDishes.Controls.Add(this.buttonAdd); + this.groupBoxDishes.Controls.Add(this.dataGridView); + this.groupBoxDishes.Dock = System.Windows.Forms.DockStyle.Bottom; + this.groupBoxDishes.Location = new System.Drawing.Point(0, 70); + this.groupBoxDishes.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.groupBoxDishes.Name = "groupBoxDishes"; + this.groupBoxDishes.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.groupBoxDishes.Size = new System.Drawing.Size(592, 206); + this.groupBoxDishes.TabIndex = 8; + this.groupBoxDishes.TabStop = false; + this.groupBoxDishes.Text = "Компоненты"; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(504, 176); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(79, 22); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(504, 150); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(79, 22); + this.buttonSave.TabIndex = 5; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(504, 98); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(79, 22); + this.buttonUpdate.TabIndex = 4; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(504, 72); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(79, 22); + this.buttonDelete.TabIndex = 3; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonEdit + // + this.buttonEdit.Location = new System.Drawing.Point(504, 46); + this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonEdit.Name = "buttonEdit"; + this.buttonEdit.Size = new System.Drawing.Size(79, 22); + this.buttonEdit.TabIndex = 2; + this.buttonEdit.Text = "Изменить"; + this.buttonEdit.UseVisualStyleBackColor = true; + this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(504, 20); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(79, 22); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ID, + this.ColumnDishName, + this.ColumnCount}); + 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.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(493, 182); + this.dataGridView.TabIndex = 0; + // + // ID + // + this.ID.HeaderText = "ID"; + this.ID.MinimumWidth = 6; + this.ID.Name = "ID"; + this.ID.Visible = false; + this.ID.Width = 125; + // + // ColumnDishName + // + this.ColumnDishName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.ColumnDishName.HeaderText = "Блюдо"; + this.ColumnDishName.MinimumWidth = 6; + this.ColumnDishName.Name = "ColumnDishName"; + this.ColumnDishName.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.ColumnDishName.Width = 312; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.MinimumWidth = 6; + this.ColumnCount.Name = "ColumnCount"; + this.ColumnCount.Width = 125; + // + // FormSetOfDishes + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(592, 276); + this.Controls.Add(this.groupBoxDishes); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelName); + this.Name = "FormSetOfDishes"; + this.Text = "Набор блюд"; + this.Load += new System.EventHandler(this.FormSetOfDishes_Load); + this.groupBoxDishes.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxPrice; + private TextBox textBoxName; + private Label labelPrice; + private Label labelName; + private GroupBox groupBoxDishes; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonEdit; + private Button buttonAdd; + private DataGridView dataGridView; + private Button buttonCancel; + private Button buttonSave; + private DataGridViewTextBoxColumn ID; + private DataGridViewTextBoxColumn ColumnDishName; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormSetOfDishes.cs b/FoodOrders/FoodOrders/FormSetOfDishes.cs new file mode 100644 index 0000000..3124b29 --- /dev/null +++ b/FoodOrders/FoodOrders/FormSetOfDishes.cs @@ -0,0 +1,207 @@ +using FoodOrders; +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.SearchModels; +using FoodOrdersDataModels.Models; +using Microsoft.Extensions.Logging; + +namespace FoodOrdersView +{ + public partial class FormSetOfDishes : Form + { + private readonly ILogger _logger; + private readonly ISetOfDishesLogic _logic; + private int? _id; + private Dictionary _set_of_dishesDishes; + public int Id { set { _id = value; } } + public FormSetOfDishes(ILogger logger, ISetOfDishesLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _set_of_dishesDishes = new Dictionary(); + } + private void FormSetOfDishes_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка набор блюд"); + try + { + var view = _logic.ReadElement(new SetOfDishesearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.SetOfDishesName; + textBoxPrice.Text = view.Price.ToString(); + _set_of_dishesDishes = view.SetOfDishesDishes ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки набор блюд"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка Блюдо набор блюд"); + try + { + if (_set_of_dishesDishes != null) + { + dataGridView.Rows.Clear(); + foreach (var sc in _set_of_dishesDishes) + { + dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.DishName, sc.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception 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(FormSetOfDishesDishes)); + if (service is FormSetOfDishesDishes form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового блюда: { DishName} - { Count}", form.ComponentModel.DishName, form.Count); + if (_set_of_dishesDishes.ContainsKey(form.Id)) + { + _set_of_dishesDishes[form.Id] = (form.ComponentModel, + form.Count); + } + else + { + _set_of_dishesDishes.Add(form.Id, (form.ComponentModel, + form.Count)); + } + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishesDishes)); + if (service is FormSetOfDishesDishes form) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _set_of_dishesDishes[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение блюда: { DishName} - { Count} ", form.ComponentModel.DishName, form.Count); + _set_of_dishesDishes[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление блюда: { DishName} - { Count} ", + dataGridView.SelectedRows[0].Cells[1].Value); _set_of_dishesDishes?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + if (_set_of_dishesDishes == null || _set_of_dishesDishes.Count == 0) + { + MessageBox.Show("Заполните Блюда", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение набор блюд"); + try + { + var model = new SetOfDishesBindingModel + { + Id = _id ?? 0, + SetOfDishesName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + SetOfDishesDishes = _set_of_dishesDishes + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения набор блюд"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + private double CalcPrice() + { + double price = 0; + foreach (var elem in _set_of_dishesDishes) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/FoodOrders/FoodOrders/FormSetOfDishes.resx b/FoodOrders/FoodOrders/FormSetOfDishes.resx new file mode 100644 index 0000000..ed24e01 --- /dev/null +++ b/FoodOrders/FoodOrders/FormSetOfDishes.resx @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs b/FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs new file mode 100644 index 0000000..01281f2 --- /dev/null +++ b/FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs @@ -0,0 +1,123 @@ +namespace FoodOrdersView +{ + partial class FormSetOfDishesDishes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer Dishes = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (Dishes != null)) + { + Dishes.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.comboBoxDish = new System.Windows.Forms.ComboBox(); + this.labelCount = new System.Windows.Forms.Label(); + this.labelDish = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(319, 80); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(80, 22); + this.buttonCancel.TabIndex = 11; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(233, 80); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(80, 22); + this.buttonSave.TabIndex = 10; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(116, 43); + this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(283, 23); + this.textBoxCount.TabIndex = 9; + // + // comboBoxDish + // + this.comboBoxDish.FormattingEnabled = true; + this.comboBoxDish.Location = new System.Drawing.Point(116, 11); + this.comboBoxDish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxDish.Name = "comboBoxDish"; + this.comboBoxDish.Size = new System.Drawing.Size(282, 23); + this.comboBoxDish.TabIndex = 8; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(10, 46); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(75, 15); + this.labelCount.TabIndex = 7; + this.labelCount.Text = "Количество:"; + // + // labelDish + // + this.labelDish.AutoSize = true; + this.labelDish.Location = new System.Drawing.Point(10, 14); + this.labelDish.Name = "labelDish"; + this.labelDish.Size = new System.Drawing.Size(75, 15); + this.labelDish.TabIndex = 6; + this.labelDish.Text = "Блюдо:"; + // + // FormSetOfDishesDishes + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(410, 115); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.comboBoxDish); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelDish); + this.Name = "FormSetOfDishesDishes"; + this.Text = "Блюдо набор блюд"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxCount; + private ComboBox comboBoxDish; + private Label labelCount; + private Label labelDish; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormSetOfDishesComponents.cs b/FoodOrders/FoodOrders/FormSetOfDishesComponents.cs new file mode 100644 index 0000000..6e2caf3 --- /dev/null +++ b/FoodOrders/FoodOrders/FormSetOfDishesComponents.cs @@ -0,0 +1,79 @@ +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.ViewModels; +using FoodOrdersDataModels.Models; + +namespace FoodOrdersView +{ + public partial class FormSetOfDishesDishes : Form + { + private readonly List? _list; + public int Id + { + get + { + return Convert.ToInt32(comboBoxDish.SelectedValue); + } + set + { + comboBoxDish.SelectedValue = value; + } + } + public IDishModel? ComponentModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set { textBoxCount.Text = value.ToString(); } + } + public FormSetOfDishesDishes(IDishLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxDish.DisplayMember = "DishName"; + comboBoxDish.ValueMember = "Id"; + comboBoxDish.DataSource = _list; + comboBoxDish.SelectedItem = null; + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле 'Количество'", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxDish.SelectedValue == null) + { + MessageBox.Show("Выберите Блюдо", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + } + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/FoodOrders/FoodOrders/FormSetOfDishesComponents.resx b/FoodOrders/FoodOrders/FormSetOfDishesComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FoodOrders/FoodOrders/FormSetOfDishesComponents.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/FoodOrders/FoodOrders/Program.cs b/FoodOrders/FoodOrders/Program.cs index c3ed338..46cfcea 100644 --- a/FoodOrders/FoodOrders/Program.cs +++ b/FoodOrders/FoodOrders/Program.cs @@ -1,7 +1,18 @@ +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.StoragesContracts; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; +using FoodOrdersView; +using FoodOrdersListImplement.Implements; +using FoodOrdersBusinessLogic.BusinessLogics; + namespace FoodOrders { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +22,34 @@ namespace FoodOrders // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + + Application.Run(_serviceProvider.GetRequiredService()); + } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + 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/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/DishLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/DishLogic.cs new file mode 100644 index 0000000..5d40c9e --- /dev/null +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/DishLogic.cs @@ -0,0 +1,112 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.StoragesContracts; +using FoodOrdersContracts.ViewModels; +using Microsoft.Extensions.Logging; + +namespace FoodOrdersBusinessLogic.BusinessLogics +{ + public class DishLogic : IDishLogic + { + private readonly ILogger _logger; + private readonly IDishestorage _Dishestorage; + public DishLogic(ILogger logger, IDishestorage + Dishestorage) + { + _logger = logger; + _Dishestorage = Dishestorage; + } + public List? ReadList(DishesearchModel? model) + { + _logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}", + model?.DishName, model?.Id); + var list = model == null ? _Dishestorage.GetFullList() : + _Dishestorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public DishViewModel? ReadElement(DishesearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. DishName:{DishName}. Id:{Id}", model.DishName, model.Id); + var element = _Dishestorage.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(DishBindingModel model) + { + CheckModel(model); + if (_Dishestorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(DishBindingModel model) + { + CheckModel(model); + if (_Dishestorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(DishBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_Dishestorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(DishBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.DishName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.DishName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Dish. DishName:{DishName}. Cost:{ Cost}. Id:{Id}", model.DishName, model.Cost, model.Id); + var element = _Dishestorage.GetElement(new DishesearchModel + { + DishName = model.DishName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs new file mode 100644 index 0000000..3b5d77c --- /dev/null +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs @@ -0,0 +1,113 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.StoragesContracts; +using FoodOrdersContracts.ViewModels; +using FoodOrdersDataModels.Enums; +using Microsoft.Extensions.Logging; + +namespace FoodOrdersBusinessLogic.BusinessLogics +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : + _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + model.Status = OrderStatus.Неизвестен; + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool DeliveryOrder(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Выдан); + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Выполняется); + } + + public bool FinishOrder(OrderBindingModel model) + { + return StatusUpdate(model, OrderStatus.Готов); + } + + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.Id < 0) + { + throw new ArgumentNullException("Некорректный идентификатор у продукта", nameof(model.Id)); + } + if (model.Count <= 0) + { + throw new ArgumentNullException("Количество продуктов в заказе должно быть больше 0", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); + } + _logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. SetOfDishesId: { SetOfDishesId}", model.Id, model.Sum, model.Id); + } + + //??? + public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) + { + CheckModel(model); + if (model.Status + 1 != newStatus) + { + _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect."); + return false; + } + model.Status = newStatus; + if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; + if (_orderStorage.Update(model) == null) + { + model.Status--; + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + } +} diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/SetOfDishesLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/SetOfDishesLogic.cs new file mode 100644 index 0000000..7d789da --- /dev/null +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/SetOfDishesLogic.cs @@ -0,0 +1,118 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.StoragesContracts; +using FoodOrdersContracts.ViewModels; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FoodOrdersBusinessLogic.BusinessLogics +{ + public class SetOfDishesLogic : ISetOfDishesLogic + { + private readonly ILogger _logger; + private readonly ISetOfDishestorage _set_of_dishesStorage; + public SetOfDishesLogic(ILogger logger, ISetOfDishestorage set_of_dishesStorage) + { + _logger = logger; + _set_of_dishesStorage = set_of_dishesStorage; + } + + public List? ReadList(SetOfDishesearchModel? model) + { + _logger.LogInformation("ReadList. SetOfDishesName:{SetOfDishesName}. Id:{Id}", + model?.SetOfDishesName, model?.Id); + var list = model == null ? _set_of_dishesStorage.GetFullList() : + _set_of_dishesStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + + public SetOfDishesViewModel? ReadElement(SetOfDishesearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. SetOfDishesName:{SetOfDishesName}. Id:{Id}", model.SetOfDishesName, model.Id); + var element = _set_of_dishesStorage.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(SetOfDishesBindingModel model) + { + CheckModel(model); + if (_set_of_dishesStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(SetOfDishesBindingModel model) + { + CheckModel(model); + if (_set_of_dishesStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(SetOfDishesBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_set_of_dishesStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(SetOfDishesBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.SetOfDishesName)) + { + throw new ArgumentNullException("Нет названия компонента", nameof(model.SetOfDishesName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Price)); + } + _logger.LogInformation("SetOfDishes. SetOfDishesName:{SetOfDishesName}. Price:{Price}. Id:{Id}", model.SetOfDishesName, model.Price, model.Id); + var element = _set_of_dishesStorage.GetElement(new SetOfDishesearchModel + { + SetOfDishesName = model.SetOfDishesName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Прдукт с таким названием уже есть"); + } + } + } +} diff --git a/FoodOrders/FoodOrdersBusinessLogic/FoodOrdersBusinessLogic.csproj b/FoodOrders/FoodOrdersBusinessLogic/FoodOrdersBusinessLogic.csproj new file mode 100644 index 0000000..554f9de --- /dev/null +++ b/FoodOrders/FoodOrdersBusinessLogic/FoodOrdersBusinessLogic.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/DishBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/DishBindingModel.cs new file mode 100644 index 0000000..bcbbf41 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/BindingModels/DishBindingModel.cs @@ -0,0 +1,11 @@ +using FoodOrdersDataModels.Models; + +namespace FoodOrdersContracts.BindingModels +{ + public class DishBindingModel : IDishModel + { + public int Id { get; set; } + public string DishName { get; set; } = string.Empty; + public double Cost { get; set; } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..5a6072e --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,17 @@ +using FoodOrdersDataModels.Enums; +using FoodOrdersDataModels.Models; + +namespace FoodOrdersContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int SetOfDishesId { get; set; } + public string SetOfDishesName { get; set; } = string.Empty; + public int Count { get; set; } + public double Sum { get; set; } + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/SetOfDishesBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/SetOfDishesBindingModel.cs new file mode 100644 index 0000000..f02f6de --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/BindingModels/SetOfDishesBindingModel.cs @@ -0,0 +1,16 @@ +using FoodOrdersDataModels.Models; + +namespace FoodOrdersContracts.BindingModels +{ + public class SetOfDishesBindingModel : ISetOfDishesModel + { + public int Id { get; set; } + public string SetOfDishesName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary SetOfDishesDishes + { + get; + set; + } = new(); + } +} diff --git a/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IDishLogic.cs b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IDishLogic.cs new file mode 100644 index 0000000..974f2b3 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IDishLogic.cs @@ -0,0 +1,15 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersContracts.BusinessLogicsContracts +{ + public interface IDishLogic + { + List? ReadList(DishesearchModel? model); + DishViewModel? ReadElement(DishesearchModel model); + bool Create(DishBindingModel model); + bool Update(DishBindingModel model); + bool Delete(DishBindingModel model); + } +} diff --git a/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IOrderLogic.cs b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..682cd91 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,15 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/ISetOfDishesLogic.cs b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/ISetOfDishesLogic.cs new file mode 100644 index 0000000..a488572 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/ISetOfDishesLogic.cs @@ -0,0 +1,15 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersContracts.BusinessLogicsContracts +{ + public interface ISetOfDishesLogic + { + List? ReadList(SetOfDishesearchModel? model); + SetOfDishesViewModel? ReadElement(SetOfDishesearchModel model); + bool Create(SetOfDishesBindingModel model); + bool Update(SetOfDishesBindingModel model); + bool Delete(SetOfDishesBindingModel model); + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/Class1.cs b/FoodOrders/FoodOrdersContracts/Class1.cs deleted file mode 100644 index c470fb5..0000000 --- a/FoodOrders/FoodOrdersContracts/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FoodOrdersContracts -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/FoodOrdersContracts.csproj b/FoodOrders/FoodOrdersContracts/FoodOrdersContracts.csproj index 132c02c..5fabb46 100644 --- a/FoodOrders/FoodOrdersContracts/FoodOrdersContracts.csproj +++ b/FoodOrders/FoodOrdersContracts/FoodOrdersContracts.csproj @@ -6,4 +6,14 @@ enable + + + + + + + + + + diff --git a/FoodOrders/FoodOrdersContracts/SearchModels/DishSearchModel.cs b/FoodOrders/FoodOrdersContracts/SearchModels/DishSearchModel.cs new file mode 100644 index 0000000..0669660 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/SearchModels/DishSearchModel.cs @@ -0,0 +1,9 @@ + +namespace FoodOrdersContracts.SearchModels +{ + public class DishesearchModel + { + public int? Id { get; set; } + public string? DishName { get; set; } + } +} diff --git a/FoodOrders/FoodOrdersContracts/SearchModels/OrderSearchModel.cs b/FoodOrders/FoodOrdersContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..c2a84ae --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,8 @@ + +namespace FoodOrdersContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/FoodOrders/FoodOrdersContracts/SearchModels/SetOfDishesSearchModel.cs b/FoodOrders/FoodOrdersContracts/SearchModels/SetOfDishesSearchModel.cs new file mode 100644 index 0000000..891bbbc --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/SearchModels/SetOfDishesSearchModel.cs @@ -0,0 +1,9 @@ + +namespace FoodOrdersContracts.SearchModels +{ + public class SetOfDishesearchModel + { + public int? Id { get; set; } + public string? SetOfDishesName { get; set; } + } +} diff --git a/FoodOrders/FoodOrdersContracts/StoragesContracts/IDishStorage.cs b/FoodOrders/FoodOrdersContracts/StoragesContracts/IDishStorage.cs new file mode 100644 index 0000000..f87eeb4 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/StoragesContracts/IDishStorage.cs @@ -0,0 +1,16 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersContracts.StoragesContracts +{ + public interface IDishestorage + { + List GetFullList(); + List GetFilteredList(DishesearchModel model); + DishViewModel? GetElement(DishesearchModel model); + DishViewModel? Insert(DishBindingModel model); + DishViewModel? Update(DishBindingModel model); + DishViewModel? Delete(DishBindingModel model); + } +} diff --git a/FoodOrders/FoodOrdersContracts/StoragesContracts/IOrderStorage.cs b/FoodOrders/FoodOrdersContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..fb625a0 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,16 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersContracts.StoragesContracts +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + } +} diff --git a/FoodOrders/FoodOrdersContracts/StoragesContracts/ISetOfDishesStorage.cs b/FoodOrders/FoodOrdersContracts/StoragesContracts/ISetOfDishesStorage.cs new file mode 100644 index 0000000..fbff2f5 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/StoragesContracts/ISetOfDishesStorage.cs @@ -0,0 +1,16 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersContracts.StoragesContracts +{ + public interface ISetOfDishestorage + { + List GetFullList(); + List GetFilteredList(SetOfDishesearchModel model); + SetOfDishesViewModel? GetElement(SetOfDishesearchModel model); + SetOfDishesViewModel? Insert(SetOfDishesBindingModel model); + SetOfDishesViewModel? Update(SetOfDishesBindingModel model); + SetOfDishesViewModel? Delete(SetOfDishesBindingModel model); + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/DishViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/DishViewModel.cs new file mode 100644 index 0000000..fb95a51 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/ViewModels/DishViewModel.cs @@ -0,0 +1,13 @@ +using FoodOrdersDataModels.Models; +using System.ComponentModel; +namespace FoodOrdersContracts.ViewModels +{ + public class DishViewModel : IDishModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string DishName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..d1aa039 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,31 @@ +using FoodOrdersDataModels.Enums; +using FoodOrdersDataModels.Models; +using System.ComponentModel; +namespace FoodOrdersContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + + public int SetOfDishesId { get; set; } + + [DisplayName("Изделие")] + public string SetOfDishesName { get; set; } = string.Empty; + + [DisplayName("Количество")] + public int Count { get; set; } + + [DisplayName("Сумма")] + public double Sum { get; set; } + + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/SetOfDishesViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/SetOfDishesViewModel.cs new file mode 100644 index 0000000..7ddda80 --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/ViewModels/SetOfDishesViewModel.cs @@ -0,0 +1,15 @@ +using FoodOrdersDataModels.Models; +using System.ComponentModel; + +namespace FoodOrdersContracts.ViewModels +{ + public class SetOfDishesViewModel : ISetOfDishesModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string SetOfDishesName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary SetOfDishesDishes {get; set;} = new(); + } +} diff --git a/FoodOrders/FoodOrdersDataModels/IComponentModel.cs b/FoodOrders/FoodOrdersDataModels/IDishModel.cs similarity index 51% rename from FoodOrders/FoodOrdersDataModels/IComponentModel.cs rename to FoodOrders/FoodOrdersDataModels/IDishModel.cs index 2e2e443..2d41383 100644 --- a/FoodOrders/FoodOrdersDataModels/IComponentModel.cs +++ b/FoodOrders/FoodOrdersDataModels/IDishModel.cs @@ -1,9 +1,9 @@  namespace FoodOrdersDataModels.Models { - public interface IComponentModel : IId + public interface IDishModel : IId { - string ComponentName { get; } + string DishName { get; } double Cost { get; } } } diff --git a/FoodOrders/FoodOrdersDataModels/IOrderModel.cs b/FoodOrders/FoodOrdersDataModels/IOrderModel.cs index 084cb40..d43445f 100644 --- a/FoodOrders/FoodOrdersDataModels/IOrderModel.cs +++ b/FoodOrders/FoodOrdersDataModels/IOrderModel.cs @@ -4,7 +4,7 @@ namespace FoodOrdersDataModels.Models { public interface IOrderModel : IId { - int ProductId { get; } + int SetOfDishesId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/FoodOrders/FoodOrdersDataModels/IProductModel.cs b/FoodOrders/FoodOrdersDataModels/IProductModel.cs deleted file mode 100644 index ba632eb..0000000 --- a/FoodOrders/FoodOrdersDataModels/IProductModel.cs +++ /dev/null @@ -1,10 +0,0 @@ - -namespace FoodOrdersDataModels.Models -{ - public interface IProductModel : IId - { - string ProductName { get; } - double Price { get; } - Dictionary ProductComponents { get; } - } -} diff --git a/FoodOrders/FoodOrdersDataModels/ISetOfDishesModel.cs b/FoodOrders/FoodOrdersDataModels/ISetOfDishesModel.cs new file mode 100644 index 0000000..62fd3b9 --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/ISetOfDishesModel.cs @@ -0,0 +1,10 @@ + +namespace FoodOrdersDataModels.Models +{ + public interface ISetOfDishesModel : IId + { + string SetOfDishesName { get; } + double Price { get; } + Dictionary SetOfDishesDishes { get; } + } +} diff --git a/FoodOrders/FoodOrdersListImplement/DataListSingleton.cs b/FoodOrders/FoodOrdersListImplement/DataListSingleton.cs new file mode 100644 index 0000000..9b7d06d --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/DataListSingleton.cs @@ -0,0 +1,26 @@ +using FoodOrdersListImplement.Models; + +namespace FoodOrdersListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Dishes { get; set; } + public List Orders { get; set; } + public List SetOfDishes { get; set; } + private DataListSingleton() + { + Dishes = new List(); + Orders = new List(); + SetOfDishes = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/FoodOrdersListImplement.csproj b/FoodOrders/FoodOrdersListImplement/FoodOrdersListImplement.csproj new file mode 100644 index 0000000..51e14c2 --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/FoodOrdersListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/FoodOrders/FoodOrdersListImplement/Implements/DishStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/DishStorage.cs new file mode 100644 index 0000000..c784e65 --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/Implements/DishStorage.cs @@ -0,0 +1,103 @@ +using FoodOrdersListImplement.Models; +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.StoragesContracts; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersListImplement.Implements +{ + public class Dishestorage : IDishestorage + { + private readonly DataListSingleton _source; + public Dishestorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var dish in _source.Dishes) + { + result.Add(dish.GetViewModel); + } + return result; + } + public List GetFilteredList(DishesearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.DishName)) + { + return result; + } + foreach (var dish in _source.Dishes) + { + if (dish.DishName.Contains(model.DishName)) + { + result.Add(dish.GetViewModel); + } + } + return result; + } + public DishViewModel? GetElement(DishesearchModel model) + { + if (string.IsNullOrEmpty(model.DishName) && !model.Id.HasValue) + { + return null; + } + foreach (var dish in _source.Dishes) + { + if ((!string.IsNullOrEmpty(model.DishName) && + dish.DishName == model.DishName) || + (model.Id.HasValue && dish.Id == model.Id)) + { + return dish.GetViewModel; + } + } + return null; + } + public DishViewModel? Insert(DishBindingModel model) + { + model.Id = 1; + foreach (var dish in _source.Dishes) + { + if (model.Id <= dish.Id) + { + model.Id = dish.Id + 1; + } + } + var newDish = Dish.Create(model); + if (newDish == null) + { + return null; + } + _source.Dishes.Add(newDish); + return newDish.GetViewModel; + } + public DishViewModel? Update(DishBindingModel model) + { + foreach (var dish in _source.Dishes) + { + if (dish.Id == model.Id) + { + dish.Update(model); + return dish.GetViewModel; + } + } + return null; + } + public DishViewModel? Delete(DishBindingModel model) + { + for (int i = 0; i < _source.Dishes.Count; ++i) + { + if (_source.Dishes[i].Id == model.Id) + { + var element = _source.Dishes[i]; + _source.Dishes.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..234a6e6 --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs @@ -0,0 +1,108 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.StoragesContracts; +using FoodOrdersContracts.ViewModels; +using FoodOrdersListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FoodOrdersListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var order in _source.Orders) + { + result.Add(order.GetViewModel); + } + return result; + } + public List GetFilteredList(OrderSearchModel model) + { + var result = new List(); + if (!model.Id.HasValue) + { + return result; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + result.Add(order.GetViewModel); + } + } + return result; + } + + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var order in _source.Orders) + { + if (model.Id.HasValue && order.Id == model.Id) + { + return order.GetViewModel; + } + } + return null; + } + public OrderViewModel? Delete(OrderBindingModel model) + { + for (int i = 0; i < _source.Orders.Count; ++i) + { + if (_source.Orders[i].Id == model.Id) + { + var element = _source.Orders[i]; + _source.Orders.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + + public OrderViewModel? Insert(OrderBindingModel model) + { + model.Id = 1; + foreach (var order in _source.Orders) + { + if (model.Id <= order.Id) + { + model.Id = order.Id + 1; + } + } + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + _source.Orders.Add(newOrder); + return newOrder.GetViewModel; + } + + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return order.GetViewModel; + } + } + return null; + } + } +} diff --git a/FoodOrders/FoodOrdersListImplement/Implements/SetOfDishesStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/SetOfDishesStorage.cs new file mode 100644 index 0000000..cefc7bb --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/Implements/SetOfDishesStorage.cs @@ -0,0 +1,103 @@ +using FoodOrdersListImplement.Models; +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.StoragesContracts; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersListImplement.Implements +{ + public class SetOfDishestorage : ISetOfDishestorage + { + private readonly DataListSingleton _source; + public SetOfDishestorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var set_of_dishes in _source.SetOfDishes) + { + result.Add(set_of_dishes.GetViewModel); + } + return result; + } + public List GetFilteredList(SetOfDishesearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.SetOfDishesName)) + { + return result; + } + foreach (var set_of_dishes in _source.SetOfDishes) + { + if (set_of_dishes.SetOfDishesName.Contains(model.SetOfDishesName)) + { + result.Add(set_of_dishes.GetViewModel); + } + } + return result; + } + public SetOfDishesViewModel? GetElement(SetOfDishesearchModel model) + { + if (string.IsNullOrEmpty(model.SetOfDishesName) && !model.Id.HasValue) + { + return null; + } + foreach (var set_of_dishes in _source.SetOfDishes) + { + if ((!string.IsNullOrEmpty(model.SetOfDishesName) && + set_of_dishes.SetOfDishesName == model.SetOfDishesName) || + (model.Id.HasValue && set_of_dishes.Id == model.Id)) + { + return set_of_dishes.GetViewModel; + } + } + return null; + } + public SetOfDishesViewModel? Insert(SetOfDishesBindingModel model) + { + model.Id = 1; + foreach (var set_of_dishes in _source.SetOfDishes) + { + if (model.Id <= set_of_dishes.Id) + { + model.Id = set_of_dishes.Id + 1; + } + } + var newSetOfDishes = SetOfDishes.Create(model); + if (newSetOfDishes == null) + { + return null; + } + _source.SetOfDishes.Add(newSetOfDishes); + return newSetOfDishes.GetViewModel; + } + public SetOfDishesViewModel? Update(SetOfDishesBindingModel model) + { + foreach (var set_of_dishes in _source.SetOfDishes) + { + if (set_of_dishes.Id == model.Id) + { + set_of_dishes.Update(model); + return set_of_dishes.GetViewModel; + } + } + return null; + } + public SetOfDishesViewModel? Delete(SetOfDishesBindingModel model) + { + for (int i = 0; i < _source.SetOfDishes.Count; ++i) + { + if (_source.SetOfDishes[i].Id == model.Id) + { + var element = _source.SetOfDishes[i]; + _source.SetOfDishes.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/Models/Component.cs b/FoodOrders/FoodOrdersListImplement/Models/Component.cs new file mode 100644 index 0000000..63f86ab --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/Models/Component.cs @@ -0,0 +1,41 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.ViewModels; +using FoodOrdersDataModels.Models; + +namespace FoodOrdersListImplement.Models +{ + public class Dish : IDishModel + { + public int Id { get; private set; } + public string DishName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Dish? Create(DishBindingModel? model) + { + if (model == null) + { + return null; + } + return new Dish() + { + Id = model.Id, + DishName = model.DishName, + Cost = model.Cost + }; + } + public void Update(DishBindingModel? model) + { + if (model == null) + { + return; + } + DishName = model.DishName; + Cost = model.Cost; + } + public DishViewModel GetViewModel => new() + { + Id = Id, + DishName = DishName, + Cost = Cost + }; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/Models/Order.cs b/FoodOrders/FoodOrdersListImplement/Models/Order.cs new file mode 100644 index 0000000..d7d4981 --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/Models/Order.cs @@ -0,0 +1,64 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.ViewModels; +using FoodOrdersDataModels.Enums; +using FoodOrdersDataModels.Models; +using System.Reflection; + +namespace FoodOrdersListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public int SetOfDishesId { get; private set; } + public string SetOfDishesName { get; private set; } = string.Empty; + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } + public DateTime DateCreate { get; private set; } + public DateTime? DateImplement { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + SetOfDishesId = model.SetOfDishesId, + SetOfDishesName = model.SetOfDishesName, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement + }; + } + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + SetOfDishesId = model.SetOfDishesId; + SetOfDishesName = model.SetOfDishesName; + Count = model.Count; + Sum = model.Sum; + Status = model.Status; + DateCreate = model.DateCreate; + DateImplement = model.DateImplement; + } + public OrderViewModel GetViewModel => new() + { + Id = Id, + SetOfDishesId = SetOfDishesId, + SetOfDishesName = SetOfDishesName, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement + }; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/Models/Product.cs b/FoodOrders/FoodOrdersListImplement/Models/Product.cs new file mode 100644 index 0000000..3616b61 --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/Models/Product.cs @@ -0,0 +1,49 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.ViewModels; +using FoodOrdersDataModels.Models; + +namespace FoodOrdersListImplement.Models +{ + public class SetOfDishes : ISetOfDishesModel + { + public int Id { get; private set; } + public string SetOfDishesName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary SetOfDishesDishes + { + get; + private set; + } = new Dictionary(); + public static SetOfDishes? Create(SetOfDishesBindingModel? model) + { + if (model == null) + { + return null; + } + return new SetOfDishes() + { + Id = model.Id, + SetOfDishesName = model.SetOfDishesName, + Price = model.Price, + SetOfDishesDishes = model.SetOfDishesDishes + }; + } + public void Update(SetOfDishesBindingModel? model) + { + if (model == null) + { + return; + } + SetOfDishesName = model.SetOfDishesName; + Price = model.Price; + SetOfDishesDishes = model.SetOfDishesDishes; + } + public SetOfDishesViewModel GetViewModel => new() + { + Id = Id, + SetOfDishesName = SetOfDishesName, + Price = Price, + SetOfDishesDishes = SetOfDishesDishes + }; + } +} \ No newline at end of file -- 2.25.1 From 20dd765c919ecbb40ea98be984bc00c40ebb4735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Feb 2023 08:32:52 +0400 Subject: [PATCH 05/12] =?UTF-8?q?9=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FoodOrders/FoodOrders/FormListSetOfDishes.cs | 8 ++++---- FoodOrders/FoodOrders/FormMain.cs | 4 ++-- .../Models/{Component.cs => Dish.cs} | 0 3 files changed, 6 insertions(+), 6 deletions(-) rename FoodOrders/FoodOrdersListImplement/Models/{Component.cs => Dish.cs} (100%) diff --git a/FoodOrders/FoodOrders/FormListSetOfDishes.cs b/FoodOrders/FoodOrders/FormListSetOfDishes.cs index cdd61f8..6a11188 100644 --- a/FoodOrders/FoodOrders/FormListSetOfDishes.cs +++ b/FoodOrders/FoodOrders/FormListSetOfDishes.cs @@ -8,8 +8,8 @@ namespace FoodOrdersView public partial class FormListSetOfDishes : Form { private readonly ILogger _logger; - private readonly IDishLogic _logic; - public FormListSetOfDishes(ILogger logger, IDishLogic logic) + private readonly ISetOfDishesLogic _logic; + public FormListSetOfDishes(ILogger logger, ISetOfDishesLogic logic) { InitializeComponent(); _logger = logger; @@ -29,7 +29,7 @@ namespace FoodOrdersView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ProdyctName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["SetOfDishesName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["SetOfDishesDishes"].Visible = false; } _logger.LogInformation("Загрузка набор блюд"); @@ -79,7 +79,7 @@ namespace FoodOrdersView _logger.LogInformation("Удаление набор блюд"); try { - if (!_logic.Delete(new DishBindingModel + if (!_logic.Delete(new SetOfDishesBindingModel { Id = id })) diff --git a/FoodOrders/FoodOrders/FormMain.cs b/FoodOrders/FoodOrders/FormMain.cs index b5c7653..0816cc6 100644 --- a/FoodOrders/FoodOrders/FormMain.cs +++ b/FoodOrders/FoodOrders/FormMain.cs @@ -50,8 +50,8 @@ namespace FoodOrdersView } private void SetOfDishesToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishes)); - if (service is FormSetOfDishes form) + var service = Program.ServiceProvider?.GetService(typeof(FormListSetOfDishes)); + if (service is FormListSetOfDishes form) { form.ShowDialog(); } diff --git a/FoodOrders/FoodOrdersListImplement/Models/Component.cs b/FoodOrders/FoodOrdersListImplement/Models/Dish.cs similarity index 100% rename from FoodOrders/FoodOrdersListImplement/Models/Component.cs rename to FoodOrders/FoodOrdersListImplement/Models/Dish.cs -- 2.25.1 From a71ea5188a5d123484657488d87939fa09186bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Feb 2023 10:11:34 +0400 Subject: [PATCH 06/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FoodOrders/FormCreateOrder.Designer.cs | 22 ++-- FoodOrders/FoodOrders/FormCreateOrder.cs | 26 ++--- FoodOrders/FoodOrders/FormDish.Designer.cs | 14 +-- FoodOrders/FoodOrders/FormDish.cs | 16 +-- FoodOrders/FoodOrders/FormDishes.Designer.cs | 14 +-- FoodOrders/FoodOrders/FormDishes.cs | 20 ++-- .../FormListSetOfDishes.Designer.cs | 12 +- FoodOrders/FoodOrders/FormListSetOfDishes.cs | 20 ++-- FoodOrders/FoodOrders/FormMain.Designer.cs | 10 +- FoodOrders/FoodOrders/FormMain.cs | 26 ++--- .../FoodOrders/FormSetOfDishes.Designer.cs | 78 ++++++------- FoodOrders/FoodOrders/FormSetOfDishes.cs | 60 +++++----- FoodOrders/FoodOrders/FormSetOfDishes.resx | 2 +- .../FormSetOfDishesComponents.Designer.cs | 52 ++++----- .../FoodOrders/FormSetOfDishesComponents.cs | 22 ++-- FoodOrders/FoodOrders/Program.cs | 18 +-- ...{SetOfDishesLogic.cs => ComponentLogic.cs} | 72 ++++++------ .../BusinessLogics/DishLogic.cs | 56 +++++----- .../BusinessLogics/OrderLogic.cs | 4 +- .../BindingModels/ComponentBindingModel.cs | 11 ++ .../BindingModels/DishBindingModel.cs | 9 +- .../BindingModels/OrderBindingModel.cs | 4 +- .../BindingModels/SetOfDishesBindingModel.cs | 16 --- .../IComponentLogic.cs | 15 +++ .../BuisnessLogicsContracts/IDishLogic.cs | 6 +- .../ISetOfDishesLogic.cs | 15 --- ...SearchModel.cs => ComponentSearchModel.cs} | 4 +- .../SearchModels/DishSearchModel.cs | 2 +- .../StoragesContracts/IComponentStorage.cs | 16 +++ .../StoragesContracts/IDishStorage.cs | 8 +- .../StoragesContracts/ISetOfDishesStorage.cs | 16 --- .../ViewModels/ComponentViewModel.cs | 13 +++ .../ViewModels/DishViewModel.cs | 6 +- .../ViewModels/OrderViewModel.cs | 4 +- .../ViewModels/SetOfDishesViewModel.cs | 15 --- .../FoodOrdersDataModels/IComponentModel.cs | 9 ++ FoodOrders/FoodOrdersDataModels/IDishModel.cs | 3 +- .../FoodOrdersDataModels/IOrderModel.cs | 2 +- .../FoodOrdersDataModels/ISetOfDishesModel.cs | 10 -- .../DataListSingleton.cs | 8 +- .../Implements/ComponentStorage.cs | 103 ++++++++++++++++++ .../Implements/DishStorage.cs | 28 ++--- .../Implements/SetOfDishesStorage.cs | 103 ------------------ .../Models/Component.cs | 41 +++++++ .../FoodOrdersListImplement/Models/Dish.cs | 16 ++- .../FoodOrdersListImplement/Models/Order.cs | 16 +-- .../FoodOrdersListImplement/Models/Product.cs | 49 --------- 47 files changed, 546 insertions(+), 546 deletions(-) rename FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/{SetOfDishesLogic.cs => ComponentLogic.cs} (52%) create mode 100644 FoodOrders/FoodOrdersContracts/BindingModels/ComponentBindingModel.cs delete mode 100644 FoodOrders/FoodOrdersContracts/BindingModels/SetOfDishesBindingModel.cs create mode 100644 FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IComponentLogic.cs delete mode 100644 FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/ISetOfDishesLogic.cs rename FoodOrders/FoodOrdersContracts/SearchModels/{SetOfDishesSearchModel.cs => ComponentSearchModel.cs} (52%) create mode 100644 FoodOrders/FoodOrdersContracts/StoragesContracts/IComponentStorage.cs delete mode 100644 FoodOrders/FoodOrdersContracts/StoragesContracts/ISetOfDishesStorage.cs create mode 100644 FoodOrders/FoodOrdersContracts/ViewModels/ComponentViewModel.cs delete mode 100644 FoodOrders/FoodOrdersContracts/ViewModels/SetOfDishesViewModel.cs create mode 100644 FoodOrders/FoodOrdersDataModels/IComponentModel.cs delete mode 100644 FoodOrders/FoodOrdersDataModels/ISetOfDishesModel.cs create mode 100644 FoodOrders/FoodOrdersListImplement/Implements/ComponentStorage.cs delete mode 100644 FoodOrders/FoodOrdersListImplement/Implements/SetOfDishesStorage.cs create mode 100644 FoodOrders/FoodOrdersListImplement/Models/Component.cs delete mode 100644 FoodOrders/FoodOrdersListImplement/Models/Product.cs diff --git a/FoodOrders/FoodOrders/FormCreateOrder.Designer.cs b/FoodOrders/FoodOrders/FormCreateOrder.Designer.cs index 96b3e0f..dce3202 100644 --- a/FoodOrders/FoodOrders/FormCreateOrder.Designer.cs +++ b/FoodOrders/FoodOrders/FormCreateOrder.Designer.cs @@ -32,7 +32,7 @@ this.buttonSave = new System.Windows.Forms.Button(); this.textBoxSum = new System.Windows.Forms.TextBox(); this.textBoxCount = new System.Windows.Forms.TextBox(); - this.comboBoxSetOfDishes = new System.Windows.Forms.ComboBox(); + this.comboBoxDish = new System.Windows.Forms.ComboBox(); this.labelSum = new System.Windows.Forms.Label(); this.labelCount = new System.Windows.Forms.Label(); this.labelName = new System.Windows.Forms.Label(); @@ -77,15 +77,15 @@ this.textBoxCount.TabIndex = 12; this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); // - // comboBoxSetOfDishes + // comboBoxDish // - this.comboBoxSetOfDishes.FormattingEnabled = true; - this.comboBoxSetOfDishes.Location = new System.Drawing.Point(93, 9); - this.comboBoxSetOfDishes.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.comboBoxSetOfDishes.Name = "comboBoxSetOfDishes"; - this.comboBoxSetOfDishes.Size = new System.Drawing.Size(230, 23); - this.comboBoxSetOfDishes.TabIndex = 11; - this.comboBoxSetOfDishes.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSetOfDishes_SelectedIndexChanged); + this.comboBoxDish.FormattingEnabled = true; + this.comboBoxDish.Location = new System.Drawing.Point(93, 9); + this.comboBoxDish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxDish.Name = "comboBoxDish"; + this.comboBoxDish.Size = new System.Drawing.Size(230, 23); + this.comboBoxDish.TabIndex = 11; + this.comboBoxDish.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDish_SelectedIndexChanged); // // labelSum // @@ -123,7 +123,7 @@ this.Controls.Add(this.buttonSave); this.Controls.Add(this.textBoxSum); this.Controls.Add(this.textBoxCount); - this.Controls.Add(this.comboBoxSetOfDishes); + this.Controls.Add(this.comboBoxDish); this.Controls.Add(this.labelSum); this.Controls.Add(this.labelCount); this.Controls.Add(this.labelName); @@ -141,7 +141,7 @@ private Button buttonSave; private TextBox textBoxSum; private TextBox textBoxCount; - private ComboBox comboBoxSetOfDishes; + private ComboBox comboBoxDish; private Label labelSum; private Label labelCount; private Label labelName; diff --git a/FoodOrders/FoodOrders/FormCreateOrder.cs b/FoodOrders/FoodOrders/FormCreateOrder.cs index 2c1ca37..554785e 100644 --- a/FoodOrders/FoodOrders/FormCreateOrder.cs +++ b/FoodOrders/FoodOrders/FormCreateOrder.cs @@ -8,9 +8,9 @@ namespace FoodOrdersView public partial class FormCreateOrder : Form { private readonly ILogger _logger; - private readonly ISetOfDishesLogic _logicS; + private readonly IDishLogic _logicS; private readonly IOrderLogic _logicO; - public FormCreateOrder(ILogger logger, ISetOfDishesLogic logicS, IOrderLogic logicO) + public FormCreateOrder(ILogger logger, IDishLogic logicS, IOrderLogic logicO) { InitializeComponent(); _logger = logger; @@ -25,10 +25,10 @@ namespace FoodOrdersView var list = _logicS.ReadList(null); if (list != null) { - comboBoxSetOfDishes.DisplayMember = "SetOfDishesName"; - comboBoxSetOfDishes.ValueMember = "Id"; - comboBoxSetOfDishes.DataSource = list; - comboBoxSetOfDishes.SelectedItem = null; + comboBoxDish.DisplayMember = "DishName"; + comboBoxDish.ValueMember = "Id"; + comboBoxDish.DataSource = list; + comboBoxDish.SelectedItem = null; } } @@ -40,12 +40,12 @@ namespace FoodOrdersView } private void CalcSum() { - if (comboBoxSetOfDishes.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) + if (comboBoxDish.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) { try { - int id = Convert.ToInt32(comboBoxSetOfDishes.SelectedValue); - var product = _logicS.ReadElement(new SetOfDishesearchModel + int id = Convert.ToInt32(comboBoxDish.SelectedValue); + var product = _logicS.ReadElement(new DishSearchModel { Id = id }); @@ -65,7 +65,7 @@ namespace FoodOrdersView { CalcSum(); } - private void ComboBoxSetOfDishes_SelectedIndexChanged(object sender, EventArgs e) + private void ComboBoxDish_SelectedIndexChanged(object sender, EventArgs e) { CalcSum(); } @@ -77,7 +77,7 @@ namespace FoodOrdersView MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (comboBoxSetOfDishes.SelectedValue == null) + if (comboBoxDish.SelectedValue == null) { MessageBox.Show("Выберите Набор блюд", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -87,8 +87,8 @@ namespace FoodOrdersView { var operationResult = _logicO.CreateOrder(new OrderBindingModel { - SetOfDishesId = Convert.ToInt32(comboBoxSetOfDishes.SelectedValue), - SetOfDishesName = comboBoxSetOfDishes.Text, + DishId = Convert.ToInt32(comboBoxDish.SelectedValue), + DishName = comboBoxDish.Text, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/FoodOrders/FoodOrders/FormDish.Designer.cs b/FoodOrders/FoodOrders/FormDish.Designer.cs index eda2ab6..905ca7b 100644 --- a/FoodOrders/FoodOrders/FormDish.Designer.cs +++ b/FoodOrders/FoodOrders/FormDish.Designer.cs @@ -1,11 +1,11 @@ namespace FoodOrdersView { - partial class FormDish + partial class FormComponent { /// /// Required designer variable. /// - private System.ComponentModel.IContainer Dishes = null; + private System.ComponentModel.IContainer Components = null; /// /// Clean up any resources being used. @@ -13,9 +13,9 @@ /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (Dishes != null)) + if (disposing && (Components != null)) { - Dishes.Dispose(); + Components.Dispose(); } base.Dispose(disposing); } @@ -92,7 +92,7 @@ this.labelBlankName.TabIndex = 6; this.labelBlankName.Text = "Название:"; // - // FormDish + // FormComponent // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -103,9 +103,9 @@ this.Controls.Add(this.textBoxName); this.Controls.Add(this.labelPrice); this.Controls.Add(this.labelBlankName); - this.Name = "FormDish"; + this.Name = "FormComponent"; this.Text = "Блюдо"; - this.Load += new System.EventHandler(this.FormDish_Load); + this.Load += new System.EventHandler(this.FormComponent_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FoodOrders/FoodOrders/FormDish.cs b/FoodOrders/FoodOrders/FormDish.cs index 806255b..03a5f08 100644 --- a/FoodOrders/FoodOrders/FormDish.cs +++ b/FoodOrders/FoodOrders/FormDish.cs @@ -5,34 +5,34 @@ using FoodOrdersContracts.BindingModels; namespace FoodOrdersView { - public partial class FormDish : Form + public partial class FormComponent : Form { private readonly ILogger _logger; - private readonly IDishLogic _logic; + private readonly IComponentLogic _logic; private int? _id; public int Id { set { _id = value; } } - public FormDish(ILogger logger, IDishLogic logic) + public FormComponent(ILogger logger, IComponentLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormDish_Load(object sender, EventArgs e) + private void FormComponent_Load(object sender, EventArgs e) { if (_id.HasValue) { try { _logger.LogInformation("Получение блюда"); - var view = _logic.ReadElement(new DishesearchModel + var view = _logic.ReadElement(new ComponentSearchModel { Id = _id.Value }); if (view != null) { - textBoxName.Text = view.DishName; + textBoxName.Text = view.ComponentName; textBoxCost.Text = view.Cost.ToString(); } } @@ -55,10 +55,10 @@ namespace FoodOrdersView _logger.LogInformation("Сохранение блюда"); try { - var model = new DishBindingModel + var model = new ComponentBindingModel { Id = _id ?? 0, - DishName = textBoxName.Text, + ComponentName = textBoxName.Text, Cost = Convert.ToDouble(textBoxCost.Text) }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); diff --git a/FoodOrders/FoodOrders/FormDishes.Designer.cs b/FoodOrders/FoodOrders/FormDishes.Designer.cs index d62400f..db6eaf1 100644 --- a/FoodOrders/FoodOrders/FormDishes.Designer.cs +++ b/FoodOrders/FoodOrders/FormDishes.Designer.cs @@ -1,11 +1,11 @@ namespace FoodOrdersView { - partial class FormDishes + partial class FormComponents { /// /// Required designer variable. /// - private System.ComponentModel.IContainer Dishes = null; + private System.ComponentModel.IContainer Components = null; /// /// Clean up any resources being used. @@ -13,9 +13,9 @@ /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (Dishes != null)) + if (disposing && (Components != null)) { - Dishes.Dispose(); + Components.Dispose(); } base.Dispose(disposing); } @@ -93,7 +93,7 @@ this.dataGridView.Size = new System.Drawing.Size(426, 348); this.dataGridView.TabIndex = 5; // - // FormDishes + // FormComponents // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -103,9 +103,9 @@ this.Controls.Add(this.buttonDelete); this.Controls.Add(this.buttonEdit); this.Controls.Add(this.buttonAdd); - this.Name = "FormDishes"; + this.Name = "FormComponents"; this.Text = "Блюда"; - this.Load += new System.EventHandler(this.FormDishes_Load); + this.Load += new System.EventHandler(this.FormComponents_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/FoodOrders/FoodOrders/FormDishes.cs b/FoodOrders/FoodOrders/FormDishes.cs index c806bcf..5b67403 100644 --- a/FoodOrders/FoodOrders/FormDishes.cs +++ b/FoodOrders/FoodOrders/FormDishes.cs @@ -5,17 +5,17 @@ using Microsoft.Extensions.Logging; namespace FoodOrdersView { - public partial class FormDishes : Form + public partial class FormComponents : Form { private readonly ILogger _logger; - private readonly IDishLogic _logic; - public FormDishes(ILogger logger, IDishLogic logic) + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormDishes_Load(object sender, EventArgs e) + private void FormComponents_Load(object sender, EventArgs e) { LoadData(); } @@ -28,7 +28,7 @@ namespace FoodOrdersView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["DishName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка Блюд"); } @@ -41,8 +41,8 @@ namespace FoodOrdersView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormDish)); - if (service is FormDish form) + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) { if (form.ShowDialog() == DialogResult.OK) { @@ -54,8 +54,8 @@ namespace FoodOrdersView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormDish)); - if (service is FormDish form) + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -75,7 +75,7 @@ namespace FoodOrdersView _logger.LogInformation("Удаление блюда"); try { - if (!_logic.Delete(new DishBindingModel + if (!_logic.Delete(new ComponentBindingModel { Id = id })) diff --git a/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs b/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs index 6353298..251f8c9 100644 --- a/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs +++ b/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs @@ -1,11 +1,11 @@ namespace FoodOrdersView { - partial class FormListSetOfDishes + partial class FormListDish { /// /// Required designer variable. /// - private System.ComponentModel.IContainer Dishes = null; + private System.ComponentModel.IContainer Components = null; /// /// Clean up any resources being used. @@ -13,9 +13,9 @@ /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (Dishes != null)) + if (disposing && (Components != null)) { - Dishes.Dispose(); + Components.Dispose(); } base.Dispose(disposing); } @@ -93,7 +93,7 @@ this.buttonAdd.UseVisualStyleBackColor = true; this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); // - // FormListSetOfDishes + // FormListDish // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -103,7 +103,7 @@ this.Controls.Add(this.buttonDelete); this.Controls.Add(this.buttonEdit); this.Controls.Add(this.buttonAdd); - this.Name = "FormListSetOfDishes"; + this.Name = "FormListDish"; this.Text = "Список набор блюд"; this.Load += new System.EventHandler(this.FormDocuments_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); diff --git a/FoodOrders/FoodOrders/FormListSetOfDishes.cs b/FoodOrders/FoodOrders/FormListSetOfDishes.cs index 6a11188..a9eca36 100644 --- a/FoodOrders/FoodOrders/FormListSetOfDishes.cs +++ b/FoodOrders/FoodOrders/FormListSetOfDishes.cs @@ -5,11 +5,11 @@ using Microsoft.Extensions.Logging; namespace FoodOrdersView { - public partial class FormListSetOfDishes : Form + public partial class FormListDish : Form { private readonly ILogger _logger; - private readonly ISetOfDishesLogic _logic; - public FormListSetOfDishes(ILogger logger, ISetOfDishesLogic logic) + private readonly IDishLogic _logic; + public FormListDish(ILogger logger, IDishLogic logic) { InitializeComponent(); _logger = logger; @@ -29,8 +29,8 @@ namespace FoodOrdersView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["SetOfDishesName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["SetOfDishesDishes"].Visible = false; + dataGridView.Columns["DishName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["DishComponents"].Visible = false; } _logger.LogInformation("Загрузка набор блюд"); } @@ -43,8 +43,8 @@ namespace FoodOrdersView private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishes)); - if (service is FormSetOfDishes form) + var service = Program.ServiceProvider?.GetService(typeof(FormDish)); + if (service is FormDish form) { if (form.ShowDialog() == DialogResult.OK) { @@ -57,8 +57,8 @@ namespace FoodOrdersView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishes)); - if (service is FormSetOfDishes form) + var service = Program.ServiceProvider?.GetService(typeof(FormDish)); + if (service is FormDish form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -79,7 +79,7 @@ namespace FoodOrdersView _logger.LogInformation("Удаление набор блюд"); try { - if (!_logic.Delete(new SetOfDishesBindingModel + if (!_logic.Delete(new DishBindingModel { Id = id })) diff --git a/FoodOrders/FoodOrders/FormMain.Designer.cs b/FoodOrders/FoodOrders/FormMain.Designer.cs index 6a6905d..a9f671f 100644 --- a/FoodOrders/FoodOrders/FormMain.Designer.cs +++ b/FoodOrders/FoodOrders/FormMain.Designer.cs @@ -5,7 +5,7 @@ /// /// Required designer variable. /// - private System.ComponentModel.IContainer Dishes = null; + private System.ComponentModel.IContainer Components = null; /// /// Clean up any resources being used. @@ -13,9 +13,9 @@ /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (Dishes != null)) + if (disposing && (Components != null)) { - Dishes.Dispose(); + Components.Dispose(); } base.Dispose(disposing); } @@ -66,14 +66,14 @@ this.БлюдаToolStripMenuItem.Name = "БлюдаToolStripMenuItem"; this.БлюдаToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.БлюдаToolStripMenuItem.Text = "Блюда"; - this.БлюдаToolStripMenuItem.Click += new System.EventHandler(this.DishesToolStripMenuItem_Click); + this.БлюдаToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); // // набор блюдToolStripMenuItem // this.наборблюдToolStripMenuItem.Name = "набор блюдToolStripMenuItem"; this.наборблюдToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.наборблюдToolStripMenuItem.Text = "Набор блюд"; - this.наборблюдToolStripMenuItem.Click += new System.EventHandler(this.SetOfDishesToolStripMenuItem_Click); + this.наборблюдToolStripMenuItem.Click += new System.EventHandler(this.DishToolStripMenuItem_Click); // // buttonUpdate // diff --git a/FoodOrders/FoodOrders/FormMain.cs b/FoodOrders/FoodOrders/FormMain.cs index 0816cc6..4c471e2 100644 --- a/FoodOrders/FoodOrders/FormMain.cs +++ b/FoodOrders/FoodOrders/FormMain.cs @@ -30,7 +30,7 @@ namespace FoodOrdersView if (list != null) { dataGridView.DataSource = list; - dataGridView.Columns["SetOfDishesId"].Visible = false; + dataGridView.Columns["DishId"].Visible = false; } _logger.LogInformation("Загрузка заказов"); } @@ -40,18 +40,18 @@ namespace FoodOrdersView MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void DishesToolStripMenuItem_Click(object sender, EventArgs e) + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormDishes)); - if (service is FormDishes form) + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) { form.ShowDialog(); } } - private void SetOfDishesToolStripMenuItem_Click(object sender, EventArgs e) + private void DishToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormListSetOfDishes)); - if (service is FormListSetOfDishes form) + var service = Program.ServiceProvider?.GetService(typeof(FormListDish)); + if (service is FormListDish form) { form.ShowDialog(); } @@ -76,8 +76,8 @@ namespace FoodOrdersView var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id, - SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value), - SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(), + DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), + DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -107,8 +107,8 @@ namespace FoodOrdersView var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id, - SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value), - SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(), + DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), + DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -138,8 +138,8 @@ namespace FoodOrdersView var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id, - SetOfDishesId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SetOfDishesId"].Value), - SetOfDishesName = dataGridView.SelectedRows[0].Cells["SetOfDishesName"].Value.ToString(), + DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), + DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), diff --git a/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs b/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs index 20c7b13..4c0256c 100644 --- a/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs +++ b/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs @@ -1,11 +1,11 @@ namespace FoodOrdersView { - partial class FormSetOfDishes + partial class FormDish { /// /// Required designer variable. /// - private System.ComponentModel.IContainer Dishes = null; + private System.ComponentModel.IContainer Components = null; /// /// Clean up any resources being used. @@ -13,9 +13,9 @@ /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (Dishes != null)) + if (disposing && (Components != null)) { - Dishes.Dispose(); + Components.Dispose(); } base.Dispose(disposing); } @@ -32,7 +32,7 @@ this.textBoxName = new System.Windows.Forms.TextBox(); this.labelPrice = new System.Windows.Forms.Label(); this.labelName = new System.Windows.Forms.Label(); - this.groupBoxDishes = new System.Windows.Forms.GroupBox(); + this.groupBoxComponents = new System.Windows.Forms.GroupBox(); this.buttonCancel = new System.Windows.Forms.Button(); this.buttonSave = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button(); @@ -41,9 +41,9 @@ this.buttonAdd = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnDishName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnComponentName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.groupBoxDishes.SuspendLayout(); + this.groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // @@ -81,24 +81,24 @@ this.labelName.TabIndex = 4; this.labelName.Text = "Название:"; // - // groupBoxDishes + // groupBoxComponents // - this.groupBoxDishes.Controls.Add(this.buttonCancel); - this.groupBoxDishes.Controls.Add(this.buttonSave); - this.groupBoxDishes.Controls.Add(this.buttonUpdate); - this.groupBoxDishes.Controls.Add(this.buttonDelete); - this.groupBoxDishes.Controls.Add(this.buttonEdit); - this.groupBoxDishes.Controls.Add(this.buttonAdd); - this.groupBoxDishes.Controls.Add(this.dataGridView); - this.groupBoxDishes.Dock = System.Windows.Forms.DockStyle.Bottom; - this.groupBoxDishes.Location = new System.Drawing.Point(0, 70); - this.groupBoxDishes.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBoxDishes.Name = "groupBoxDishes"; - this.groupBoxDishes.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBoxDishes.Size = new System.Drawing.Size(592, 206); - this.groupBoxDishes.TabIndex = 8; - this.groupBoxDishes.TabStop = false; - this.groupBoxDishes.Text = "Компоненты"; + this.groupBoxComponents.Controls.Add(this.buttonCancel); + this.groupBoxComponents.Controls.Add(this.buttonSave); + this.groupBoxComponents.Controls.Add(this.buttonUpdate); + this.groupBoxComponents.Controls.Add(this.buttonDelete); + this.groupBoxComponents.Controls.Add(this.buttonEdit); + this.groupBoxComponents.Controls.Add(this.buttonAdd); + this.groupBoxComponents.Controls.Add(this.dataGridView); + this.groupBoxComponents.Dock = System.Windows.Forms.DockStyle.Bottom; + this.groupBoxComponents.Location = new System.Drawing.Point(0, 70); + this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.groupBoxComponents.Name = "groupBoxComponents"; + this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.groupBoxComponents.Size = new System.Drawing.Size(592, 206); + this.groupBoxComponents.TabIndex = 8; + this.groupBoxComponents.TabStop = false; + this.groupBoxComponents.Text = "Компоненты"; // // buttonCancel // @@ -171,7 +171,7 @@ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.ID, - this.ColumnDishName, + this.ColumnComponentName, this.ColumnCount}); this.dataGridView.Location = new System.Drawing.Point(5, 20); this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); @@ -189,14 +189,14 @@ this.ID.Visible = false; this.ID.Width = 125; // - // ColumnDishName + // ColumnComponentName // - this.ColumnDishName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.ColumnDishName.HeaderText = "Блюдо"; - this.ColumnDishName.MinimumWidth = 6; - this.ColumnDishName.Name = "ColumnDishName"; - this.ColumnDishName.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.ColumnDishName.Width = 312; + this.ColumnComponentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.ColumnComponentName.HeaderText = "Блюдо"; + this.ColumnComponentName.MinimumWidth = 6; + this.ColumnComponentName.Name = "ColumnComponentName"; + this.ColumnComponentName.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.ColumnComponentName.Width = 312; // // ColumnCount // @@ -205,20 +205,20 @@ this.ColumnCount.Name = "ColumnCount"; this.ColumnCount.Width = 125; // - // FormSetOfDishes + // FormDish // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(592, 276); - this.Controls.Add(this.groupBoxDishes); + this.Controls.Add(this.groupBoxComponents); this.Controls.Add(this.textBoxPrice); this.Controls.Add(this.textBoxName); this.Controls.Add(this.labelPrice); this.Controls.Add(this.labelName); - this.Name = "FormSetOfDishes"; + this.Name = "FormDish"; this.Text = "Набор блюд"; - this.Load += new System.EventHandler(this.FormSetOfDishes_Load); - this.groupBoxDishes.ResumeLayout(false); + this.Load += new System.EventHandler(this.FormDish_Load); + this.groupBoxComponents.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -231,7 +231,7 @@ private TextBox textBoxName; private Label labelPrice; private Label labelName; - private GroupBox groupBoxDishes; + private GroupBox groupBoxComponents; private Button buttonUpdate; private Button buttonDelete; private Button buttonEdit; @@ -240,7 +240,7 @@ private Button buttonCancel; private Button buttonSave; private DataGridViewTextBoxColumn ID; - private DataGridViewTextBoxColumn ColumnDishName; + private DataGridViewTextBoxColumn ColumnComponentName; private DataGridViewTextBoxColumn ColumnCount; } } \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormSetOfDishes.cs b/FoodOrders/FoodOrders/FormSetOfDishes.cs index 3124b29..1f02fd2 100644 --- a/FoodOrders/FoodOrders/FormSetOfDishes.cs +++ b/FoodOrders/FoodOrders/FormSetOfDishes.cs @@ -7,36 +7,36 @@ using Microsoft.Extensions.Logging; namespace FoodOrdersView { - public partial class FormSetOfDishes : Form + public partial class FormDish : Form { private readonly ILogger _logger; - private readonly ISetOfDishesLogic _logic; + private readonly IDishLogic _logic; private int? _id; - private Dictionary _set_of_dishesDishes; + private Dictionary _dishComponents; public int Id { set { _id = value; } } - public FormSetOfDishes(ILogger logger, ISetOfDishesLogic logic) + public FormDish(ILogger logger, IDishLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; - _set_of_dishesDishes = new Dictionary(); + _dishComponents = new Dictionary(); } - private void FormSetOfDishes_Load(object sender, EventArgs e) + private void FormDish_Load(object sender, EventArgs e) { if (_id.HasValue) { _logger.LogInformation("Загрузка набор блюд"); try { - var view = _logic.ReadElement(new SetOfDishesearchModel + var view = _logic.ReadElement(new DishSearchModel { Id = _id.Value }); if (view != null) { - textBoxName.Text = view.SetOfDishesName; + textBoxName.Text = view.DishName; textBoxPrice.Text = view.Price.ToString(); - _set_of_dishesDishes = view.SetOfDishesDishes ?? new Dictionary(); + _dishComponents = view.DishComponents ?? new Dictionary(); LoadData(); } } @@ -53,12 +53,12 @@ namespace FoodOrdersView _logger.LogInformation("Загрузка Блюдо набор блюд"); try { - if (_set_of_dishesDishes != null) + if (_dishComponents != null) { dataGridView.Rows.Clear(); - foreach (var sc in _set_of_dishesDishes) + foreach (var sc in _dishComponents) { - dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.DishName, sc.Value.Item2 }); + dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.ComponentName, sc.Value.Item2 }); } textBoxPrice.Text = CalcPrice().ToString(); } @@ -71,8 +71,8 @@ namespace FoodOrdersView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishesDishes)); - if (service is FormSetOfDishesDishes form) + var service = Program.ServiceProvider?.GetService(typeof(FormDishComponents)); + if (service is FormDishComponents form) { if (form.ShowDialog() == DialogResult.OK) { @@ -80,15 +80,15 @@ namespace FoodOrdersView { return; } - _logger.LogInformation("Добавление нового блюда: { DishName} - { Count}", form.ComponentModel.DishName, form.Count); - if (_set_of_dishesDishes.ContainsKey(form.Id)) + _logger.LogInformation("Добавление нового блюда: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + if (_dishComponents.ContainsKey(form.Id)) { - _set_of_dishesDishes[form.Id] = (form.ComponentModel, + _dishComponents[form.Id] = (form.ComponentModel, form.Count); } else { - _set_of_dishesDishes.Add(form.Id, (form.ComponentModel, + _dishComponents.Add(form.Id, (form.ComponentModel, form.Count)); } LoadData(); @@ -99,21 +99,21 @@ namespace FoodOrdersView { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormSetOfDishesDishes)); - if (service is FormSetOfDishesDishes form) + var service = Program.ServiceProvider?.GetService(typeof(FormDishComponents)); + if (service is FormDishComponents form) { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); form.Id = id; - form.Count = _set_of_dishesDishes[id].Item2; + form.Count = _dishComponents[id].Item2; if (form.ShowDialog() == DialogResult.OK) { if (form.ComponentModel == null) { return; } - _logger.LogInformation("Изменение блюда: { DishName} - { Count} ", form.ComponentModel.DishName, form.Count); - _set_of_dishesDishes[form.Id] = (form.ComponentModel, form.Count); + _logger.LogInformation("Изменение блюда: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); + _dishComponents[form.Id] = (form.ComponentModel, form.Count); LoadData(); } } @@ -128,8 +128,8 @@ namespace FoodOrdersView { try { - _logger.LogInformation("Удаление блюда: { DishName} - { Count} ", - dataGridView.SelectedRows[0].Cells[1].Value); _set_of_dishesDishes?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + _logger.LogInformation("Удаление блюда: { ComponentName} - { Count} ", + dataGridView.SelectedRows[0].Cells[1].Value); _dishComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } catch (Exception ex) { @@ -158,7 +158,7 @@ namespace FoodOrdersView MessageBoxIcon.Error); return; } - if (_set_of_dishesDishes == null || _set_of_dishesDishes.Count == 0) + if (_dishComponents == null || _dishComponents.Count == 0) { MessageBox.Show("Заполните Блюда", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -167,12 +167,12 @@ namespace FoodOrdersView _logger.LogInformation("Сохранение набор блюд"); try { - var model = new SetOfDishesBindingModel + var model = new DishBindingModel { Id = _id ?? 0, - SetOfDishesName = textBoxName.Text, + DishName = textBoxName.Text, Price = Convert.ToDouble(textBoxPrice.Text), - SetOfDishesDishes = _set_of_dishesDishes + DishComponents = _dishComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -197,7 +197,7 @@ namespace FoodOrdersView private double CalcPrice() { double price = 0; - foreach (var elem in _set_of_dishesDishes) + foreach (var elem in _dishComponents) { price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); } diff --git a/FoodOrders/FoodOrders/FormSetOfDishes.resx b/FoodOrders/FoodOrders/FormSetOfDishes.resx index ed24e01..8e6d533 100644 --- a/FoodOrders/FoodOrders/FormSetOfDishes.resx +++ b/FoodOrders/FoodOrders/FormSetOfDishes.resx @@ -60,7 +60,7 @@ True - + True diff --git a/FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs b/FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs index 01281f2..e5a4330 100644 --- a/FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs +++ b/FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs @@ -1,11 +1,11 @@ namespace FoodOrdersView { - partial class FormSetOfDishesDishes + partial class FormDishComponents { /// /// Required designer variable. /// - private System.ComponentModel.IContainer Dishes = null; + private System.ComponentModel.IContainer Components = null; /// /// Clean up any resources being used. @@ -13,9 +13,9 @@ /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (disposing && (Dishes != null)) + if (disposing && (Components != null)) { - Dishes.Dispose(); + Components.Dispose(); } base.Dispose(disposing); } @@ -31,9 +31,9 @@ this.buttonCancel = new System.Windows.Forms.Button(); this.buttonSave = new System.Windows.Forms.Button(); this.textBoxCount = new System.Windows.Forms.TextBox(); - this.comboBoxDish = new System.Windows.Forms.ComboBox(); + this.comboBoxComponent = new System.Windows.Forms.ComboBox(); this.labelCount = new System.Windows.Forms.Label(); - this.labelDish = new System.Windows.Forms.Label(); + this.labelComponent = new System.Windows.Forms.Label(); this.SuspendLayout(); // // buttonCancel @@ -66,14 +66,14 @@ this.textBoxCount.Size = new System.Drawing.Size(283, 23); this.textBoxCount.TabIndex = 9; // - // comboBoxDish + // comboBoxComponent // - this.comboBoxDish.FormattingEnabled = true; - this.comboBoxDish.Location = new System.Drawing.Point(116, 11); - this.comboBoxDish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.comboBoxDish.Name = "comboBoxDish"; - this.comboBoxDish.Size = new System.Drawing.Size(282, 23); - this.comboBoxDish.TabIndex = 8; + this.comboBoxComponent.FormattingEnabled = true; + this.comboBoxComponent.Location = new System.Drawing.Point(116, 11); + this.comboBoxComponent.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxComponent.Name = "comboBoxComponent"; + this.comboBoxComponent.Size = new System.Drawing.Size(282, 23); + this.comboBoxComponent.TabIndex = 8; // // labelCount // @@ -84,16 +84,16 @@ this.labelCount.TabIndex = 7; this.labelCount.Text = "Количество:"; // - // labelDish + // labelComponent // - this.labelDish.AutoSize = true; - this.labelDish.Location = new System.Drawing.Point(10, 14); - this.labelDish.Name = "labelDish"; - this.labelDish.Size = new System.Drawing.Size(75, 15); - this.labelDish.TabIndex = 6; - this.labelDish.Text = "Блюдо:"; + this.labelComponent.AutoSize = true; + this.labelComponent.Location = new System.Drawing.Point(10, 14); + this.labelComponent.Name = "labelComponent"; + this.labelComponent.Size = new System.Drawing.Size(75, 15); + this.labelComponent.TabIndex = 6; + this.labelComponent.Text = "Блюдо:"; // - // FormSetOfDishesDishes + // FormDishComponents // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -101,10 +101,10 @@ this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonSave); this.Controls.Add(this.textBoxCount); - this.Controls.Add(this.comboBoxDish); + this.Controls.Add(this.comboBoxComponent); this.Controls.Add(this.labelCount); - this.Controls.Add(this.labelDish); - this.Name = "FormSetOfDishesDishes"; + this.Controls.Add(this.labelComponent); + this.Name = "FormDishComponents"; this.Text = "Блюдо набор блюд"; this.ResumeLayout(false); this.PerformLayout(); @@ -116,8 +116,8 @@ private Button buttonCancel; private Button buttonSave; private TextBox textBoxCount; - private ComboBox comboBoxDish; + private ComboBox comboBoxComponent; private Label labelCount; - private Label labelDish; + private Label labelComponent; } } \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormSetOfDishesComponents.cs b/FoodOrders/FoodOrders/FormSetOfDishesComponents.cs index 6e2caf3..5ee296c 100644 --- a/FoodOrders/FoodOrders/FormSetOfDishesComponents.cs +++ b/FoodOrders/FoodOrders/FormSetOfDishesComponents.cs @@ -4,21 +4,21 @@ using FoodOrdersDataModels.Models; namespace FoodOrdersView { - public partial class FormSetOfDishesDishes : Form + public partial class FormDishComponents : Form { - private readonly List? _list; + private readonly List? _list; public int Id { get { - return Convert.ToInt32(comboBoxDish.SelectedValue); + return Convert.ToInt32(comboBoxComponent.SelectedValue); } set { - comboBoxDish.SelectedValue = value; + comboBoxComponent.SelectedValue = value; } } - public IDishModel? ComponentModel + public IComponentModel? ComponentModel { get { @@ -41,16 +41,16 @@ namespace FoodOrdersView get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } } - public FormSetOfDishesDishes(IDishLogic logic) + public FormDishComponents(IComponentLogic logic) { InitializeComponent(); _list = logic.ReadList(null); if (_list != null) { - comboBoxDish.DisplayMember = "DishName"; - comboBoxDish.ValueMember = "Id"; - comboBoxDish.DataSource = _list; - comboBoxDish.SelectedItem = null; + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; } } private void ButtonSave_Click(object sender, EventArgs e) @@ -61,7 +61,7 @@ namespace FoodOrdersView MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (comboBoxDish.SelectedValue == null) + if (comboBoxComponent.SelectedValue == null) { MessageBox.Show("Выберите Блюдо", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/FoodOrders/FoodOrders/Program.cs b/FoodOrders/FoodOrders/Program.cs index 46cfcea..8597c4a 100644 --- a/FoodOrders/FoodOrders/Program.cs +++ b/FoodOrders/FoodOrders/Program.cs @@ -37,19 +37,19 @@ namespace FoodOrders option.SetMinimumLevel(LogLevel.Information); option.AddNLog("nlog.config"); }); - 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(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/SetOfDishesLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/ComponentLogic.cs similarity index 52% rename from FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/SetOfDishesLogic.cs rename to FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/ComponentLogic.cs index 7d789da..7a86b71 100644 --- a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/SetOfDishesLogic.cs +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/ComponentLogic.cs @@ -4,30 +4,25 @@ using FoodOrdersContracts.SearchModels; using FoodOrdersContracts.StoragesContracts; using FoodOrdersContracts.ViewModels; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace FoodOrdersBusinessLogic.BusinessLogics { - public class SetOfDishesLogic : ISetOfDishesLogic + public class ComponentLogic : IComponentLogic { private readonly ILogger _logger; - private readonly ISetOfDishestorage _set_of_dishesStorage; - public SetOfDishesLogic(ILogger logger, ISetOfDishestorage set_of_dishesStorage) + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage + ComponentStorage) { _logger = logger; - _set_of_dishesStorage = set_of_dishesStorage; + _componentStorage = ComponentStorage; } - - public List? ReadList(SetOfDishesearchModel? model) + public List? ReadList(ComponentSearchModel? model) { - _logger.LogInformation("ReadList. SetOfDishesName:{SetOfDishesName}. Id:{Id}", - model?.SetOfDishesName, model?.Id); - var list = model == null ? _set_of_dishesStorage.GetFullList() : - _set_of_dishesStorage.GetFilteredList(model); + _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}", + model?.ComponentName, model?.Id); + var list = model == null ? _componentStorage.GetFullList() : + _componentStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -36,15 +31,14 @@ namespace FoodOrdersBusinessLogic.BusinessLogics _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } - - public SetOfDishesViewModel? ReadElement(SetOfDishesearchModel model) + public ComponentViewModel? ReadElement(ComponentSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } - _logger.LogInformation("ReadElement. SetOfDishesName:{SetOfDishesName}. Id:{Id}", model.SetOfDishesName, model.Id); - var element = _set_of_dishesStorage.GetElement(model); + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{Id}", model.ComponentName, model.Id); + var element = _componentStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); @@ -53,40 +47,39 @@ namespace FoodOrdersBusinessLogic.BusinessLogics _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); return element; } - - public bool Create(SetOfDishesBindingModel model) + public bool Create(ComponentBindingModel model) { CheckModel(model); - if (_set_of_dishesStorage.Insert(model) == null) + if (_componentStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; } return true; } - - public bool Update(SetOfDishesBindingModel model) + public bool Update(ComponentBindingModel model) { CheckModel(model); - if (_set_of_dishesStorage.Update(model) == null) + if (_componentStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); return false; } return true; } - public bool Delete(SetOfDishesBindingModel model) + public bool Delete(ComponentBindingModel model) { CheckModel(model, false); _logger.LogInformation("Delete. Id:{Id}", model.Id); - if (_set_of_dishesStorage.Delete(model) == null) + if (_componentStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; } return true; } - private void CheckModel(SetOfDishesBindingModel model, bool withParams = true) + private void CheckModel(ComponentBindingModel model, bool withParams = + true) { if (model == null) { @@ -96,23 +89,24 @@ namespace FoodOrdersBusinessLogic.BusinessLogics { return; } - if (string.IsNullOrEmpty(model.SetOfDishesName)) + if (string.IsNullOrEmpty(model.ComponentName)) { - throw new ArgumentNullException("Нет названия компонента", nameof(model.SetOfDishesName)); + throw new ArgumentNullException("Нет названия компонента", + nameof(model.ComponentName)); } - if (model.Price <= 0) + if (model.Cost <= 0) { - throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Price)); + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); } - _logger.LogInformation("SetOfDishes. SetOfDishesName:{SetOfDishesName}. Price:{Price}. Id:{Id}", model.SetOfDishesName, model.Price, model.Id); - var element = _set_of_dishesStorage.GetElement(new SetOfDishesearchModel - { - SetOfDishesName = model.SetOfDishesName - }); + _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id:{Id}", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); if (element != null && element.Id != model.Id) { - throw new InvalidOperationException("Прдукт с таким названием уже есть"); + throw new InvalidOperationException("Компонент с таким названием уже есть"); } } } -} +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/DishLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/DishLogic.cs index 5d40c9e..bd8e613 100644 --- a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/DishLogic.cs +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/DishLogic.cs @@ -4,25 +4,30 @@ using FoodOrdersContracts.SearchModels; using FoodOrdersContracts.StoragesContracts; using FoodOrdersContracts.ViewModels; using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace FoodOrdersBusinessLogic.BusinessLogics { public class DishLogic : IDishLogic { private readonly ILogger _logger; - private readonly IDishestorage _Dishestorage; - public DishLogic(ILogger logger, IDishestorage - Dishestorage) + private readonly IDishStorage _dishStorage; + public DishLogic(ILogger logger, IDishStorage dishStorage) { _logger = logger; - _Dishestorage = Dishestorage; + _dishStorage = dishStorage; } - public List? ReadList(DishesearchModel? model) + + public List? ReadList(DishSearchModel? model) { _logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}", model?.DishName, model?.Id); - var list = model == null ? _Dishestorage.GetFullList() : - _Dishestorage.GetFilteredList(model); + var list = model == null ? _dishStorage.GetFullList() : + _dishStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -31,14 +36,15 @@ namespace FoodOrdersBusinessLogic.BusinessLogics _logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; } - public DishViewModel? ReadElement(DishesearchModel model) + + public DishViewModel? ReadElement(DishSearchModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } _logger.LogInformation("ReadElement. DishName:{DishName}. Id:{Id}", model.DishName, model.Id); - var element = _Dishestorage.GetElement(model); + var element = _dishStorage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement element not found"); @@ -47,20 +53,22 @@ namespace FoodOrdersBusinessLogic.BusinessLogics _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); return element; } + public bool Create(DishBindingModel model) { CheckModel(model); - if (_Dishestorage.Insert(model) == null) + if (_dishStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; } return true; } + public bool Update(DishBindingModel model) { CheckModel(model); - if (_Dishestorage.Update(model) == null) + if (_dishStorage.Update(model) == null) { _logger.LogWarning("Update operation failed"); return false; @@ -71,15 +79,14 @@ namespace FoodOrdersBusinessLogic.BusinessLogics { CheckModel(model, false); _logger.LogInformation("Delete. Id:{Id}", model.Id); - if (_Dishestorage.Delete(model) == null) + if (_dishStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; } return true; } - private void CheckModel(DishBindingModel model, bool withParams = - true) + private void CheckModel(DishBindingModel model, bool withParams = true) { if (model == null) { @@ -91,22 +98,21 @@ namespace FoodOrdersBusinessLogic.BusinessLogics } if (string.IsNullOrEmpty(model.DishName)) { - throw new ArgumentNullException("Нет названия компонента", - nameof(model.DishName)); + throw new ArgumentNullException("Нет названия компонента", nameof(model.DishName)); } - if (model.Cost <= 0) + if (model.Price <= 0) { - throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost)); + throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Price)); } - _logger.LogInformation("Dish. DishName:{DishName}. Cost:{ Cost}. Id:{Id}", model.DishName, model.Cost, model.Id); - var element = _Dishestorage.GetElement(new DishesearchModel - { - DishName = model.DishName - }); + _logger.LogInformation("Dish. DishName:{DishName}. Price:{Price}. Id:{Id}", model.DishName, model.Price, model.Id); + var element = _dishStorage.GetElement(new DishSearchModel + { + DishName = model.DishName + }); if (element != null && element.Id != model.Id) { - throw new InvalidOperationException("Компонент с таким названием уже есть"); + throw new InvalidOperationException("Прдукт с таким названием уже есть"); } } } -} \ No newline at end of file +} diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs index 3b5d77c..c63cd43 100644 --- a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs @@ -20,7 +20,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics public List? ReadList(OrderSearchModel? model) { - _logger.LogInformation("ReadList. DishName:{DishName}. Id:{Id}", model?.Id); + _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}", model?.Id); var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); if (list == null) @@ -87,7 +87,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics { throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); } - _logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. SetOfDishesId: { SetOfDishesId}", model.Id, model.Sum, model.Id); + _logger.LogInformation("Order. OrderID:{Id}. Sum:{ Sum}. DishId: { DishId}", model.Id, model.Sum, model.Id); } //??? diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/ComponentBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..9bd6f2d --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,11 @@ +using FoodOrdersDataModels.Models; + +namespace FoodOrdersContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/DishBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/DishBindingModel.cs index bcbbf41..982fcce 100644 --- a/FoodOrders/FoodOrdersContracts/BindingModels/DishBindingModel.cs +++ b/FoodOrders/FoodOrdersContracts/BindingModels/DishBindingModel.cs @@ -6,6 +6,11 @@ namespace FoodOrdersContracts.BindingModels { public int Id { get; set; } public string DishName { get; set; } = string.Empty; - public double Cost { get; set; } + public double Price { get; set; } + public Dictionary DishComponents + { + get; + set; + } = new(); } -} \ No newline at end of file +} diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs index 5a6072e..3da89d2 100644 --- a/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs +++ b/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs @@ -6,8 +6,8 @@ namespace FoodOrdersContracts.BindingModels public class OrderBindingModel : IOrderModel { public int Id { get; set; } - public int SetOfDishesId { get; set; } - public string SetOfDishesName { get; set; } = string.Empty; + public int DishId { get; set; } + public string DishName { get; set; } = string.Empty; public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/SetOfDishesBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/SetOfDishesBindingModel.cs deleted file mode 100644 index f02f6de..0000000 --- a/FoodOrders/FoodOrdersContracts/BindingModels/SetOfDishesBindingModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FoodOrdersDataModels.Models; - -namespace FoodOrdersContracts.BindingModels -{ - public class SetOfDishesBindingModel : ISetOfDishesModel - { - public int Id { get; set; } - public string SetOfDishesName { get; set; } = string.Empty; - public double Price { get; set; } - public Dictionary SetOfDishesDishes - { - get; - set; - } = new(); - } -} diff --git a/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IComponentLogic.cs b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..2e830fd --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,15 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} diff --git a/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IDishLogic.cs b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IDishLogic.cs index 974f2b3..8051e71 100644 --- a/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IDishLogic.cs +++ b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/IDishLogic.cs @@ -6,10 +6,10 @@ namespace FoodOrdersContracts.BusinessLogicsContracts { public interface IDishLogic { - List? ReadList(DishesearchModel? model); - DishViewModel? ReadElement(DishesearchModel model); + List? ReadList(DishSearchModel? model); + DishViewModel? ReadElement(DishSearchModel model); bool Create(DishBindingModel model); bool Update(DishBindingModel model); bool Delete(DishBindingModel model); } -} +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/ISetOfDishesLogic.cs b/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/ISetOfDishesLogic.cs deleted file mode 100644 index a488572..0000000 --- a/FoodOrders/FoodOrdersContracts/BuisnessLogicsContracts/ISetOfDishesLogic.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FoodOrdersContracts.BindingModels; -using FoodOrdersContracts.SearchModels; -using FoodOrdersContracts.ViewModels; - -namespace FoodOrdersContracts.BusinessLogicsContracts -{ - public interface ISetOfDishesLogic - { - List? ReadList(SetOfDishesearchModel? model); - SetOfDishesViewModel? ReadElement(SetOfDishesearchModel model); - bool Create(SetOfDishesBindingModel model); - bool Update(SetOfDishesBindingModel model); - bool Delete(SetOfDishesBindingModel model); - } -} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/SearchModels/SetOfDishesSearchModel.cs b/FoodOrders/FoodOrdersContracts/SearchModels/ComponentSearchModel.cs similarity index 52% rename from FoodOrders/FoodOrdersContracts/SearchModels/SetOfDishesSearchModel.cs rename to FoodOrders/FoodOrdersContracts/SearchModels/ComponentSearchModel.cs index 891bbbc..2b83bb5 100644 --- a/FoodOrders/FoodOrdersContracts/SearchModels/SetOfDishesSearchModel.cs +++ b/FoodOrders/FoodOrdersContracts/SearchModels/ComponentSearchModel.cs @@ -1,9 +1,9 @@  namespace FoodOrdersContracts.SearchModels { - public class SetOfDishesearchModel + public class ComponentSearchModel { public int? Id { get; set; } - public string? SetOfDishesName { get; set; } + public string? ComponentName { get; set; } } } diff --git a/FoodOrders/FoodOrdersContracts/SearchModels/DishSearchModel.cs b/FoodOrders/FoodOrdersContracts/SearchModels/DishSearchModel.cs index 0669660..4adf0e1 100644 --- a/FoodOrders/FoodOrdersContracts/SearchModels/DishSearchModel.cs +++ b/FoodOrders/FoodOrdersContracts/SearchModels/DishSearchModel.cs @@ -1,7 +1,7 @@  namespace FoodOrdersContracts.SearchModels { - public class DishesearchModel + public class DishSearchModel { public int? Id { get; set; } public string? DishName { get; set; } diff --git a/FoodOrders/FoodOrdersContracts/StoragesContracts/IComponentStorage.cs b/FoodOrders/FoodOrdersContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..d86f0cf --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,16 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersContracts.StoragesContracts +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} diff --git a/FoodOrders/FoodOrdersContracts/StoragesContracts/IDishStorage.cs b/FoodOrders/FoodOrdersContracts/StoragesContracts/IDishStorage.cs index f87eeb4..1e95068 100644 --- a/FoodOrders/FoodOrdersContracts/StoragesContracts/IDishStorage.cs +++ b/FoodOrders/FoodOrdersContracts/StoragesContracts/IDishStorage.cs @@ -4,13 +4,13 @@ using FoodOrdersContracts.ViewModels; namespace FoodOrdersContracts.StoragesContracts { - public interface IDishestorage + public interface IDishStorage { List GetFullList(); - List GetFilteredList(DishesearchModel model); - DishViewModel? GetElement(DishesearchModel model); + List GetFilteredList(DishSearchModel model); + DishViewModel? GetElement(DishSearchModel model); DishViewModel? Insert(DishBindingModel model); DishViewModel? Update(DishBindingModel model); DishViewModel? Delete(DishBindingModel model); } -} +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/StoragesContracts/ISetOfDishesStorage.cs b/FoodOrders/FoodOrdersContracts/StoragesContracts/ISetOfDishesStorage.cs deleted file mode 100644 index fbff2f5..0000000 --- a/FoodOrders/FoodOrdersContracts/StoragesContracts/ISetOfDishesStorage.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FoodOrdersContracts.BindingModels; -using FoodOrdersContracts.SearchModels; -using FoodOrdersContracts.ViewModels; - -namespace FoodOrdersContracts.StoragesContracts -{ - public interface ISetOfDishestorage - { - List GetFullList(); - List GetFilteredList(SetOfDishesearchModel model); - SetOfDishesViewModel? GetElement(SetOfDishesearchModel model); - SetOfDishesViewModel? Insert(SetOfDishesBindingModel model); - SetOfDishesViewModel? Update(SetOfDishesBindingModel model); - SetOfDishesViewModel? Delete(SetOfDishesBindingModel model); - } -} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/ComponentViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..a569dba --- /dev/null +++ b/FoodOrders/FoodOrdersContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,13 @@ +using FoodOrdersDataModels.Models; +using System.ComponentModel; +namespace FoodOrdersContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/DishViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/DishViewModel.cs index fb95a51..76e4723 100644 --- a/FoodOrders/FoodOrdersContracts/ViewModels/DishViewModel.cs +++ b/FoodOrders/FoodOrdersContracts/ViewModels/DishViewModel.cs @@ -1,13 +1,15 @@ using FoodOrdersDataModels.Models; using System.ComponentModel; + namespace FoodOrdersContracts.ViewModels { public class DishViewModel : IDishModel { public int Id { get; set; } - [DisplayName("Название компонента")] + [DisplayName("Название изделия")] public string DishName { get; set; } = string.Empty; [DisplayName("Цена")] - public double Cost { get; set; } + public double Price { get; set; } + public Dictionary DishComponents {get; set;} = new(); } } diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs index d1aa039..de316fa 100644 --- a/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs +++ b/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs @@ -8,10 +8,10 @@ namespace FoodOrdersContracts.ViewModels [DisplayName("Номер")] public int Id { get; set; } - public int SetOfDishesId { get; set; } + public int DishId { get; set; } [DisplayName("Изделие")] - public string SetOfDishesName { get; set; } = string.Empty; + public string DishName { get; set; } = string.Empty; [DisplayName("Количество")] public int Count { get; set; } diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/SetOfDishesViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/SetOfDishesViewModel.cs deleted file mode 100644 index 7ddda80..0000000 --- a/FoodOrders/FoodOrdersContracts/ViewModels/SetOfDishesViewModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using FoodOrdersDataModels.Models; -using System.ComponentModel; - -namespace FoodOrdersContracts.ViewModels -{ - public class SetOfDishesViewModel : ISetOfDishesModel - { - public int Id { get; set; } - [DisplayName("Название изделия")] - public string SetOfDishesName { get; set; } = string.Empty; - [DisplayName("Цена")] - public double Price { get; set; } - public Dictionary SetOfDishesDishes {get; set;} = new(); - } -} diff --git a/FoodOrders/FoodOrdersDataModels/IComponentModel.cs b/FoodOrders/FoodOrdersDataModels/IComponentModel.cs new file mode 100644 index 0000000..2e2e443 --- /dev/null +++ b/FoodOrders/FoodOrdersDataModels/IComponentModel.cs @@ -0,0 +1,9 @@ + +namespace FoodOrdersDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + } +} diff --git a/FoodOrders/FoodOrdersDataModels/IDishModel.cs b/FoodOrders/FoodOrdersDataModels/IDishModel.cs index 2d41383..cca6f22 100644 --- a/FoodOrders/FoodOrdersDataModels/IDishModel.cs +++ b/FoodOrders/FoodOrdersDataModels/IDishModel.cs @@ -4,6 +4,7 @@ namespace FoodOrdersDataModels.Models public interface IDishModel : IId { string DishName { get; } - double Cost { get; } + double Price { get; } + Dictionary DishComponents { get; } } } diff --git a/FoodOrders/FoodOrdersDataModels/IOrderModel.cs b/FoodOrders/FoodOrdersDataModels/IOrderModel.cs index d43445f..134fd34 100644 --- a/FoodOrders/FoodOrdersDataModels/IOrderModel.cs +++ b/FoodOrders/FoodOrdersDataModels/IOrderModel.cs @@ -4,7 +4,7 @@ namespace FoodOrdersDataModels.Models { public interface IOrderModel : IId { - int SetOfDishesId { get; } + int DishId { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/FoodOrders/FoodOrdersDataModels/ISetOfDishesModel.cs b/FoodOrders/FoodOrdersDataModels/ISetOfDishesModel.cs deleted file mode 100644 index 62fd3b9..0000000 --- a/FoodOrders/FoodOrdersDataModels/ISetOfDishesModel.cs +++ /dev/null @@ -1,10 +0,0 @@ - -namespace FoodOrdersDataModels.Models -{ - public interface ISetOfDishesModel : IId - { - string SetOfDishesName { get; } - double Price { get; } - Dictionary SetOfDishesDishes { get; } - } -} diff --git a/FoodOrders/FoodOrdersListImplement/DataListSingleton.cs b/FoodOrders/FoodOrdersListImplement/DataListSingleton.cs index 9b7d06d..d8e4c35 100644 --- a/FoodOrders/FoodOrdersListImplement/DataListSingleton.cs +++ b/FoodOrders/FoodOrdersListImplement/DataListSingleton.cs @@ -5,14 +5,14 @@ namespace FoodOrdersListImplement public class DataListSingleton { private static DataListSingleton? _instance; - public List Dishes { get; set; } + public List Components { get; set; } public List Orders { get; set; } - public List SetOfDishes { get; set; } + public List Dish { get; set; } private DataListSingleton() { - Dishes = new List(); + Components = new List(); Orders = new List(); - SetOfDishes = new List(); + Dish = new List(); } public static DataListSingleton GetInstance() { diff --git a/FoodOrders/FoodOrdersListImplement/Implements/ComponentStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/ComponentStorage.cs new file mode 100644 index 0000000..d8ba6cb --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/Implements/ComponentStorage.cs @@ -0,0 +1,103 @@ +using FoodOrdersListImplement.Models; +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.StoragesContracts; +using FoodOrdersContracts.ViewModels; + +namespace FoodOrdersListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/Implements/DishStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/DishStorage.cs index c784e65..c751142 100644 --- a/FoodOrders/FoodOrdersListImplement/Implements/DishStorage.cs +++ b/FoodOrders/FoodOrdersListImplement/Implements/DishStorage.cs @@ -6,23 +6,23 @@ using FoodOrdersContracts.ViewModels; namespace FoodOrdersListImplement.Implements { - public class Dishestorage : IDishestorage + public class DishStorage : IDishStorage { private readonly DataListSingleton _source; - public Dishestorage() + public DishStorage() { _source = DataListSingleton.GetInstance(); } public List GetFullList() { var result = new List(); - foreach (var dish in _source.Dishes) + foreach (var dish in _source.Dish) { result.Add(dish.GetViewModel); } return result; } - public List GetFilteredList(DishesearchModel + public List GetFilteredList(DishSearchModel model) { var result = new List(); @@ -30,7 +30,7 @@ namespace FoodOrdersListImplement.Implements { return result; } - foreach (var dish in _source.Dishes) + foreach (var dish in _source.Dish) { if (dish.DishName.Contains(model.DishName)) { @@ -39,13 +39,13 @@ namespace FoodOrdersListImplement.Implements } return result; } - public DishViewModel? GetElement(DishesearchModel model) + public DishViewModel? GetElement(DishSearchModel model) { if (string.IsNullOrEmpty(model.DishName) && !model.Id.HasValue) { return null; } - foreach (var dish in _source.Dishes) + foreach (var dish in _source.Dish) { if ((!string.IsNullOrEmpty(model.DishName) && dish.DishName == model.DishName) || @@ -59,7 +59,7 @@ namespace FoodOrdersListImplement.Implements public DishViewModel? Insert(DishBindingModel model) { model.Id = 1; - foreach (var dish in _source.Dishes) + foreach (var dish in _source.Dish) { if (model.Id <= dish.Id) { @@ -71,12 +71,12 @@ namespace FoodOrdersListImplement.Implements { return null; } - _source.Dishes.Add(newDish); + _source.Dish.Add(newDish); return newDish.GetViewModel; } public DishViewModel? Update(DishBindingModel model) { - foreach (var dish in _source.Dishes) + foreach (var dish in _source.Dish) { if (dish.Id == model.Id) { @@ -88,12 +88,12 @@ namespace FoodOrdersListImplement.Implements } public DishViewModel? Delete(DishBindingModel model) { - for (int i = 0; i < _source.Dishes.Count; ++i) + for (int i = 0; i < _source.Dish.Count; ++i) { - if (_source.Dishes[i].Id == model.Id) + if (_source.Dish[i].Id == model.Id) { - var element = _source.Dishes[i]; - _source.Dishes.RemoveAt(i); + var element = _source.Dish[i]; + _source.Dish.RemoveAt(i); return element.GetViewModel; } } diff --git a/FoodOrders/FoodOrdersListImplement/Implements/SetOfDishesStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/SetOfDishesStorage.cs deleted file mode 100644 index cefc7bb..0000000 --- a/FoodOrders/FoodOrdersListImplement/Implements/SetOfDishesStorage.cs +++ /dev/null @@ -1,103 +0,0 @@ -using FoodOrdersListImplement.Models; -using FoodOrdersContracts.BindingModels; -using FoodOrdersContracts.SearchModels; -using FoodOrdersContracts.StoragesContracts; -using FoodOrdersContracts.ViewModels; - -namespace FoodOrdersListImplement.Implements -{ - public class SetOfDishestorage : ISetOfDishestorage - { - private readonly DataListSingleton _source; - public SetOfDishestorage() - { - _source = DataListSingleton.GetInstance(); - } - public List GetFullList() - { - var result = new List(); - foreach (var set_of_dishes in _source.SetOfDishes) - { - result.Add(set_of_dishes.GetViewModel); - } - return result; - } - public List GetFilteredList(SetOfDishesearchModel - model) - { - var result = new List(); - if (string.IsNullOrEmpty(model.SetOfDishesName)) - { - return result; - } - foreach (var set_of_dishes in _source.SetOfDishes) - { - if (set_of_dishes.SetOfDishesName.Contains(model.SetOfDishesName)) - { - result.Add(set_of_dishes.GetViewModel); - } - } - return result; - } - public SetOfDishesViewModel? GetElement(SetOfDishesearchModel model) - { - if (string.IsNullOrEmpty(model.SetOfDishesName) && !model.Id.HasValue) - { - return null; - } - foreach (var set_of_dishes in _source.SetOfDishes) - { - if ((!string.IsNullOrEmpty(model.SetOfDishesName) && - set_of_dishes.SetOfDishesName == model.SetOfDishesName) || - (model.Id.HasValue && set_of_dishes.Id == model.Id)) - { - return set_of_dishes.GetViewModel; - } - } - return null; - } - public SetOfDishesViewModel? Insert(SetOfDishesBindingModel model) - { - model.Id = 1; - foreach (var set_of_dishes in _source.SetOfDishes) - { - if (model.Id <= set_of_dishes.Id) - { - model.Id = set_of_dishes.Id + 1; - } - } - var newSetOfDishes = SetOfDishes.Create(model); - if (newSetOfDishes == null) - { - return null; - } - _source.SetOfDishes.Add(newSetOfDishes); - return newSetOfDishes.GetViewModel; - } - public SetOfDishesViewModel? Update(SetOfDishesBindingModel model) - { - foreach (var set_of_dishes in _source.SetOfDishes) - { - if (set_of_dishes.Id == model.Id) - { - set_of_dishes.Update(model); - return set_of_dishes.GetViewModel; - } - } - return null; - } - public SetOfDishesViewModel? Delete(SetOfDishesBindingModel model) - { - for (int i = 0; i < _source.SetOfDishes.Count; ++i) - { - if (_source.SetOfDishes[i].Id == model.Id) - { - var element = _source.SetOfDishes[i]; - _source.SetOfDishes.RemoveAt(i); - return element.GetViewModel; - } - } - return null; - } - } -} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/Models/Component.cs b/FoodOrders/FoodOrdersListImplement/Models/Component.cs new file mode 100644 index 0000000..2510fb9 --- /dev/null +++ b/FoodOrders/FoodOrdersListImplement/Models/Component.cs @@ -0,0 +1,41 @@ +using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.ViewModels; +using FoodOrdersDataModels.Models; + +namespace FoodOrdersListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/Models/Dish.cs b/FoodOrders/FoodOrdersListImplement/Models/Dish.cs index 63f86ab..f9d40a4 100644 --- a/FoodOrders/FoodOrdersListImplement/Models/Dish.cs +++ b/FoodOrders/FoodOrdersListImplement/Models/Dish.cs @@ -8,7 +8,12 @@ namespace FoodOrdersListImplement.Models { public int Id { get; private set; } public string DishName { get; private set; } = string.Empty; - public double Cost { get; set; } + public double Price { get; private set; } + public Dictionary DishComponents + { + get; + private set; + } = new Dictionary(); public static Dish? Create(DishBindingModel? model) { if (model == null) @@ -19,7 +24,8 @@ namespace FoodOrdersListImplement.Models { Id = model.Id, DishName = model.DishName, - Cost = model.Cost + Price = model.Price, + DishComponents = model.DishComponents }; } public void Update(DishBindingModel? model) @@ -29,13 +35,15 @@ namespace FoodOrdersListImplement.Models return; } DishName = model.DishName; - Cost = model.Cost; + Price = model.Price; + DishComponents = model.DishComponents; } public DishViewModel GetViewModel => new() { Id = Id, DishName = DishName, - Cost = Cost + Price = Price, + DishComponents = DishComponents }; } } \ No newline at end of file diff --git a/FoodOrders/FoodOrdersListImplement/Models/Order.cs b/FoodOrders/FoodOrdersListImplement/Models/Order.cs index d7d4981..152eb9b 100644 --- a/FoodOrders/FoodOrdersListImplement/Models/Order.cs +++ b/FoodOrders/FoodOrdersListImplement/Models/Order.cs @@ -9,8 +9,8 @@ namespace FoodOrdersListImplement.Models public class Order : IOrderModel { public int Id { get; private set; } - public int SetOfDishesId { get; private set; } - public string SetOfDishesName { get; private set; } = string.Empty; + public int DishId { get; private set; } + public string DishName { get; private set; } = string.Empty; public int Count { get; private set; } public double Sum { get; private set; } public OrderStatus Status { get; private set; } @@ -26,8 +26,8 @@ namespace FoodOrdersListImplement.Models return new Order() { Id = model.Id, - SetOfDishesId = model.SetOfDishesId, - SetOfDishesName = model.SetOfDishesName, + DishId = model.DishId, + DishName = model.DishName, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -41,8 +41,8 @@ namespace FoodOrdersListImplement.Models { return; } - SetOfDishesId = model.SetOfDishesId; - SetOfDishesName = model.SetOfDishesName; + DishId = model.DishId; + DishName = model.DishName; Count = model.Count; Sum = model.Sum; Status = model.Status; @@ -52,8 +52,8 @@ namespace FoodOrdersListImplement.Models public OrderViewModel GetViewModel => new() { Id = Id, - SetOfDishesId = SetOfDishesId, - SetOfDishesName = SetOfDishesName, + DishId = DishId, + DishName = DishName, Count = Count, Sum = Sum, Status = Status, diff --git a/FoodOrders/FoodOrdersListImplement/Models/Product.cs b/FoodOrders/FoodOrdersListImplement/Models/Product.cs deleted file mode 100644 index 3616b61..0000000 --- a/FoodOrders/FoodOrdersListImplement/Models/Product.cs +++ /dev/null @@ -1,49 +0,0 @@ -using FoodOrdersContracts.BindingModels; -using FoodOrdersContracts.ViewModels; -using FoodOrdersDataModels.Models; - -namespace FoodOrdersListImplement.Models -{ - public class SetOfDishes : ISetOfDishesModel - { - public int Id { get; private set; } - public string SetOfDishesName { get; private set; } = string.Empty; - public double Price { get; private set; } - public Dictionary SetOfDishesDishes - { - get; - private set; - } = new Dictionary(); - public static SetOfDishes? Create(SetOfDishesBindingModel? model) - { - if (model == null) - { - return null; - } - return new SetOfDishes() - { - Id = model.Id, - SetOfDishesName = model.SetOfDishesName, - Price = model.Price, - SetOfDishesDishes = model.SetOfDishesDishes - }; - } - public void Update(SetOfDishesBindingModel? model) - { - if (model == null) - { - return; - } - SetOfDishesName = model.SetOfDishesName; - Price = model.Price; - SetOfDishesDishes = model.SetOfDishesDishes; - } - public SetOfDishesViewModel GetViewModel => new() - { - Id = Id, - SetOfDishesName = SetOfDishesName, - Price = Price, - SetOfDishesDishes = SetOfDishesDishes - }; - } -} \ No newline at end of file -- 2.25.1 From de165b866f568a706d272d947c424c7467b679b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Feb 2023 10:15:19 +0400 Subject: [PATCH 07/12] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FoodOrders/FormComponent.Designer.cs | 123 +++++++++ FoodOrders/FoodOrders/FormComponent.cs | 87 +++++++ ...istSetOfDishes.resx => FormComponent.resx} | 0 ...Designer.cs => FormComponents.Designer.cs} | 108 ++++---- ...rmListSetOfDishes.cs => FormComponents.cs} | 43 ++- ...hesComponents.resx => FormComponents.resx} | 0 FoodOrders/FoodOrders/FormDish.Designer.cs | 223 ++++++++++++---- FoodOrders/FoodOrders/FormDish.cs | 164 ++++++++++-- FoodOrders/FoodOrders/FormDish.resx | 9 + ...gner.cs => FormDishComponents.Designer.cs} | 0 ...hesComponents.cs => FormDishComponents.cs} | 0 ...tOfDishes.resx => FormDishComponents.resx} | 9 - FoodOrders/FoodOrders/FormDishes.Designer.cs | 108 ++++---- FoodOrders/FoodOrders/FormDishes.cs | 43 +-- FoodOrders/FoodOrders/FormMain.cs | 4 +- .../FoodOrders/FormSetOfDishes.Designer.cs | 246 ------------------ FoodOrders/FoodOrders/FormSetOfDishes.cs | 207 --------------- FoodOrders/FoodOrders/Program.cs | 2 +- 18 files changed, 688 insertions(+), 688 deletions(-) create mode 100644 FoodOrders/FoodOrders/FormComponent.Designer.cs create mode 100644 FoodOrders/FoodOrders/FormComponent.cs rename FoodOrders/FoodOrders/{FormListSetOfDishes.resx => FormComponent.resx} (100%) rename FoodOrders/FoodOrders/{FormListSetOfDishes.Designer.cs => FormComponents.Designer.cs} (88%) rename FoodOrders/FoodOrders/{FormListSetOfDishes.cs => FormComponents.cs} (71%) rename FoodOrders/FoodOrders/{FormSetOfDishesComponents.resx => FormComponents.resx} (100%) rename FoodOrders/FoodOrders/{FormSetOfDishesComponents.Designer.cs => FormDishComponents.Designer.cs} (100%) rename FoodOrders/FoodOrders/{FormSetOfDishesComponents.cs => FormDishComponents.cs} (100%) rename FoodOrders/FoodOrders/{FormSetOfDishes.resx => FormDishComponents.resx} (83%) delete mode 100644 FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs delete mode 100644 FoodOrders/FoodOrders/FormSetOfDishes.cs diff --git a/FoodOrders/FoodOrders/FormComponent.Designer.cs b/FoodOrders/FoodOrders/FormComponent.Designer.cs new file mode 100644 index 0000000..905ca7b --- /dev/null +++ b/FoodOrders/FoodOrders/FormComponent.Designer.cs @@ -0,0 +1,123 @@ +namespace FoodOrdersView +{ + partial class FormComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer Components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (Components != null)) + { + Components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.textBoxCost = new System.Windows.Forms.TextBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelPrice = new System.Windows.Forms.Label(); + this.labelBlankName = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(200, 73); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(82, 22); + this.buttonCancel.TabIndex = 11; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(112, 73); + this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(82, 22); + this.buttonSave.TabIndex = 10; + this.buttonSave.Text = "Сохранить"; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // textBoxCost + // + this.textBoxCost.Location = new System.Drawing.Point(111, 38); + this.textBoxCost.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxCost.Name = "textBoxCost"; + this.textBoxCost.Size = new System.Drawing.Size(183, 23); + this.textBoxCost.TabIndex = 9; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(111, 11); + this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(329, 23); + this.textBoxName.TabIndex = 8; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(12, 37); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(38, 15); + this.labelPrice.TabIndex = 7; + this.labelPrice.Text = "Цена:"; + // + // labelBlankName + // + this.labelBlankName.AutoSize = true; + this.labelBlankName.Location = new System.Drawing.Point(12, 14); + this.labelBlankName.Name = "labelBlankName"; + this.labelBlankName.Size = new System.Drawing.Size(62, 15); + this.labelBlankName.TabIndex = 6; + this.labelBlankName.Text = "Название:"; + // + // FormComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(448, 106); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.textBoxCost); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelPrice); + this.Controls.Add(this.labelBlankName); + this.Name = "FormComponent"; + this.Text = "Блюдо"; + this.Load += new System.EventHandler(this.FormComponent_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxCost; + private TextBox textBoxName; + private Label labelPrice; + private Label labelBlankName; + } +} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormComponent.cs b/FoodOrders/FoodOrders/FormComponent.cs new file mode 100644 index 0000000..03a5f08 --- /dev/null +++ b/FoodOrders/FoodOrders/FormComponent.cs @@ -0,0 +1,87 @@ +using Microsoft.Extensions.Logging; +using FoodOrdersContracts.BusinessLogicsContracts; +using FoodOrdersContracts.SearchModels; +using FoodOrdersContracts.BindingModels; + +namespace FoodOrdersView +{ + public partial class FormComponent : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + + public FormComponent(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение блюда"); + var view = _logic.ReadElement(new ComponentSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения блюда"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение блюда"); + try + { + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения блюда"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + } +} diff --git a/FoodOrders/FoodOrders/FormListSetOfDishes.resx b/FoodOrders/FoodOrders/FormComponent.resx similarity index 100% rename from FoodOrders/FoodOrders/FormListSetOfDishes.resx rename to FoodOrders/FoodOrders/FormComponent.resx diff --git a/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs b/FoodOrders/FoodOrders/FormComponents.Designer.cs similarity index 88% rename from FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs rename to FoodOrders/FoodOrders/FormComponents.Designer.cs index 251f8c9..db6eaf1 100644 --- a/FoodOrders/FoodOrders/FormListSetOfDishes.Designer.cs +++ b/FoodOrders/FoodOrders/FormComponents.Designer.cs @@ -1,6 +1,6 @@ namespace FoodOrdersView { - partial class FormListDish + partial class FormComponents { /// /// Required designer variable. @@ -28,14 +28,58 @@ /// private void InitializeComponent() { - this.dataGridView = new System.Windows.Forms.DataGridView(); 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(); + this.dataGridView = new System.Windows.Forms.DataGridView(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(432, 186); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(130, 22); + this.buttonUpdate.TabIndex = 9; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(432, 160); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(130, 22); + this.buttonDelete.TabIndex = 8; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); + // + // buttonEdit + // + this.buttonEdit.Location = new System.Drawing.Point(432, 134); + this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonEdit.Name = "buttonEdit"; + this.buttonEdit.Size = new System.Drawing.Size(130, 22); + this.buttonEdit.TabIndex = 7; + this.buttonEdit.Text = "Изменить"; + this.buttonEdit.UseVisualStyleBackColor = true; + this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(432, 108); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(130, 22); + this.buttonAdd.TabIndex = 6; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; @@ -46,66 +90,22 @@ this.dataGridView.Name = "dataGridView"; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(426, 345); - this.dataGridView.TabIndex = 10; + this.dataGridView.Size = new System.Drawing.Size(426, 348); + this.dataGridView.TabIndex = 5; // - // buttonUpdate - // - this.buttonUpdate.Location = new System.Drawing.Point(432, 183); - this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonUpdate.Name = "buttonUpdate"; - this.buttonUpdate.Size = new System.Drawing.Size(130, 22); - this.buttonUpdate.TabIndex = 14; - this.buttonUpdate.Text = "Обновить"; - this.buttonUpdate.UseVisualStyleBackColor = true; - this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click); - // - // buttonDelete - // - this.buttonDelete.Location = new System.Drawing.Point(432, 157); - this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonDelete.Name = "buttonDelete"; - this.buttonDelete.Size = new System.Drawing.Size(130, 22); - this.buttonDelete.TabIndex = 13; - this.buttonDelete.Text = "Удалить"; - this.buttonDelete.UseVisualStyleBackColor = true; - this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click); - // - // buttonEdit - // - this.buttonEdit.Location = new System.Drawing.Point(432, 131); - this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonEdit.Name = "buttonEdit"; - this.buttonEdit.Size = new System.Drawing.Size(130, 22); - this.buttonEdit.TabIndex = 12; - this.buttonEdit.Text = "Изменить"; - this.buttonEdit.UseVisualStyleBackColor = true; - this.buttonEdit.Click += new System.EventHandler(this.ButtonEdit_Click); - // - // buttonAdd - // - this.buttonAdd.Location = new System.Drawing.Point(432, 105); - this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(130, 22); - this.buttonAdd.TabIndex = 11; - this.buttonAdd.Text = "Добавить"; - this.buttonAdd.UseVisualStyleBackColor = true; - this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); - // - // FormListDish + // FormComponents // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(570, 345); + this.ClientSize = new System.Drawing.Size(571, 348); this.Controls.Add(this.dataGridView); this.Controls.Add(this.buttonUpdate); this.Controls.Add(this.buttonDelete); this.Controls.Add(this.buttonEdit); this.Controls.Add(this.buttonAdd); - this.Name = "FormListDish"; - this.Text = "Список набор блюд"; - this.Load += new System.EventHandler(this.FormDocuments_Load); + this.Name = "FormComponents"; + this.Text = "Блюда"; + this.Load += new System.EventHandler(this.FormComponents_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); @@ -113,10 +113,10 @@ #endregion - private DataGridView dataGridView; private Button buttonUpdate; private Button buttonDelete; private Button buttonEdit; private Button buttonAdd; + private DataGridView dataGridView; } } \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormListSetOfDishes.cs b/FoodOrders/FoodOrders/FormComponents.cs similarity index 71% rename from FoodOrders/FoodOrders/FormListSetOfDishes.cs rename to FoodOrders/FoodOrders/FormComponents.cs index a9eca36..5b67403 100644 --- a/FoodOrders/FoodOrders/FormListSetOfDishes.cs +++ b/FoodOrders/FoodOrders/FormComponents.cs @@ -5,18 +5,17 @@ using Microsoft.Extensions.Logging; namespace FoodOrdersView { - public partial class FormListDish : Form + public partial class FormComponents : Form { private readonly ILogger _logger; - private readonly IDishLogic _logic; - public FormListDish(ILogger logger, IDishLogic logic) + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - - private void FormDocuments_Load(object sender, EventArgs e) + private void FormComponents_Load(object sender, EventArgs e) { LoadData(); } @@ -29,22 +28,21 @@ namespace FoodOrdersView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["DishName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["DishComponents"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } - _logger.LogInformation("Загрузка набор блюд"); + _logger.LogInformation("Загрузка Блюд"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки набор блюд"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _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(FormDish)); - if (service is FormDish form) + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) { if (form.ShowDialog() == DialogResult.OK) { @@ -52,13 +50,12 @@ namespace FoodOrdersView } } } - - private void ButtonEdit_Click(object sender, EventArgs e) + private void ButtonUpd_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormDish)); - if (service is FormDish form) + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -68,18 +65,17 @@ namespace FoodOrdersView } } } - - private void ButtonDelete_Click(object sender, EventArgs e) + private void ButtonDel_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { 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 DishBindingModel + if (!_logic.Delete(new ComponentBindingModel { Id = id })) @@ -90,14 +86,13 @@ namespace FoodOrdersView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления набор блюд"); + _logger.LogError(ex, "Ошибка удаления блюда"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } - - private void ButtonUpdate_Click(object sender, EventArgs e) + private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); } diff --git a/FoodOrders/FoodOrders/FormSetOfDishesComponents.resx b/FoodOrders/FoodOrders/FormComponents.resx similarity index 100% rename from FoodOrders/FoodOrders/FormSetOfDishesComponents.resx rename to FoodOrders/FoodOrders/FormComponents.resx diff --git a/FoodOrders/FoodOrders/FormDish.Designer.cs b/FoodOrders/FoodOrders/FormDish.Designer.cs index 905ca7b..4c0256c 100644 --- a/FoodOrders/FoodOrders/FormDish.Designer.cs +++ b/FoodOrders/FoodOrders/FormDish.Designer.cs @@ -1,6 +1,6 @@ namespace FoodOrdersView { - partial class FormComponent + partial class FormDish { /// /// Required designer variable. @@ -28,84 +28,198 @@ /// private void InitializeComponent() { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSave = new System.Windows.Forms.Button(); - this.textBoxCost = new System.Windows.Forms.TextBox(); + this.textBoxPrice = new System.Windows.Forms.TextBox(); this.textBoxName = new System.Windows.Forms.TextBox(); this.labelPrice = new System.Windows.Forms.Label(); - this.labelBlankName = new System.Windows.Forms.Label(); + this.labelName = new System.Windows.Forms.Label(); + this.groupBoxComponents = new System.Windows.Forms.GroupBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = 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(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnComponentName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBoxComponents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(90, 36); + this.textBoxPrice.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(138, 23); + this.textBoxPrice.TabIndex = 7; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(90, 11); + this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(276, 23); + this.textBoxName.TabIndex = 6; + // + // labelPrice + // + this.labelPrice.AutoSize = true; + this.labelPrice.Location = new System.Drawing.Point(14, 41); + this.labelPrice.Name = "labelPrice"; + this.labelPrice.Size = new System.Drawing.Size(70, 15); + this.labelPrice.TabIndex = 5; + this.labelPrice.Text = "Стоимость:"; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(14, 14); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(62, 15); + this.labelName.TabIndex = 4; + this.labelName.Text = "Название:"; + // + // groupBoxComponents + // + this.groupBoxComponents.Controls.Add(this.buttonCancel); + this.groupBoxComponents.Controls.Add(this.buttonSave); + this.groupBoxComponents.Controls.Add(this.buttonUpdate); + this.groupBoxComponents.Controls.Add(this.buttonDelete); + this.groupBoxComponents.Controls.Add(this.buttonEdit); + this.groupBoxComponents.Controls.Add(this.buttonAdd); + this.groupBoxComponents.Controls.Add(this.dataGridView); + this.groupBoxComponents.Dock = System.Windows.Forms.DockStyle.Bottom; + this.groupBoxComponents.Location = new System.Drawing.Point(0, 70); + this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.groupBoxComponents.Name = "groupBoxComponents"; + this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.groupBoxComponents.Size = new System.Drawing.Size(592, 206); + this.groupBoxComponents.TabIndex = 8; + this.groupBoxComponents.TabStop = false; + this.groupBoxComponents.Text = "Компоненты"; + // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(200, 73); + this.buttonCancel.Location = new System.Drawing.Point(504, 176); this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(82, 22); - this.buttonCancel.TabIndex = 11; + this.buttonCancel.Size = new System.Drawing.Size(79, 22); + this.buttonCancel.TabIndex = 6; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // buttonSave // - this.buttonSave.Location = new System.Drawing.Point(112, 73); + this.buttonSave.Location = new System.Drawing.Point(504, 150); this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(82, 22); - this.buttonSave.TabIndex = 10; + this.buttonSave.Size = new System.Drawing.Size(79, 22); + this.buttonSave.TabIndex = 5; this.buttonSave.Text = "Сохранить"; this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); // - // textBoxCost + // buttonUpdate // - this.textBoxCost.Location = new System.Drawing.Point(111, 38); - this.textBoxCost.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.textBoxCost.Name = "textBoxCost"; - this.textBoxCost.Size = new System.Drawing.Size(183, 23); - this.textBoxCost.TabIndex = 9; + this.buttonUpdate.Location = new System.Drawing.Point(504, 98); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(79, 22); + this.buttonUpdate.TabIndex = 4; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); // - // textBoxName + // buttonDelete // - this.textBoxName.Location = new System.Drawing.Point(111, 11); - this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(329, 23); - this.textBoxName.TabIndex = 8; + this.buttonDelete.Location = new System.Drawing.Point(504, 72); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(79, 22); + this.buttonDelete.TabIndex = 3; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); // - // labelPrice + // buttonEdit // - this.labelPrice.AutoSize = true; - this.labelPrice.Location = new System.Drawing.Point(12, 37); - this.labelPrice.Name = "labelPrice"; - this.labelPrice.Size = new System.Drawing.Size(38, 15); - this.labelPrice.TabIndex = 7; - this.labelPrice.Text = "Цена:"; + this.buttonEdit.Location = new System.Drawing.Point(504, 46); + this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonEdit.Name = "buttonEdit"; + this.buttonEdit.Size = new System.Drawing.Size(79, 22); + this.buttonEdit.TabIndex = 2; + this.buttonEdit.Text = "Изменить"; + this.buttonEdit.UseVisualStyleBackColor = true; + this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click); // - // labelBlankName + // buttonAdd // - this.labelBlankName.AutoSize = true; - this.labelBlankName.Location = new System.Drawing.Point(12, 14); - this.labelBlankName.Name = "labelBlankName"; - this.labelBlankName.Size = new System.Drawing.Size(62, 15); - this.labelBlankName.TabIndex = 6; - this.labelBlankName.Text = "Название:"; + this.buttonAdd.Location = new System.Drawing.Point(504, 20); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(79, 22); + this.buttonAdd.TabIndex = 1; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); // - // FormComponent + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ID, + this.ColumnComponentName, + this.ColumnCount}); + 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.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(493, 182); + this.dataGridView.TabIndex = 0; + // + // ID + // + this.ID.HeaderText = "ID"; + this.ID.MinimumWidth = 6; + this.ID.Name = "ID"; + this.ID.Visible = false; + this.ID.Width = 125; + // + // ColumnComponentName + // + this.ColumnComponentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.ColumnComponentName.HeaderText = "Блюдо"; + this.ColumnComponentName.MinimumWidth = 6; + this.ColumnComponentName.Name = "ColumnComponentName"; + this.ColumnComponentName.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.ColumnComponentName.Width = 312; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.MinimumWidth = 6; + this.ColumnCount.Name = "ColumnCount"; + this.ColumnCount.Width = 125; + // + // FormDish // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(448, 106); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonSave); - this.Controls.Add(this.textBoxCost); + this.ClientSize = new System.Drawing.Size(592, 276); + this.Controls.Add(this.groupBoxComponents); + this.Controls.Add(this.textBoxPrice); this.Controls.Add(this.textBoxName); this.Controls.Add(this.labelPrice); - this.Controls.Add(this.labelBlankName); - this.Name = "FormComponent"; - this.Text = "Блюдо"; - this.Load += new System.EventHandler(this.FormComponent_Load); + this.Controls.Add(this.labelName); + this.Name = "FormDish"; + this.Text = "Набор блюд"; + this.Load += new System.EventHandler(this.FormDish_Load); + this.groupBoxComponents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -113,11 +227,20 @@ #endregion - private Button buttonCancel; - private Button buttonSave; - private TextBox textBoxCost; + private TextBox textBoxPrice; private TextBox textBoxName; private Label labelPrice; - private Label labelBlankName; + private Label labelName; + private GroupBox groupBoxComponents; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonEdit; + private Button buttonAdd; + private DataGridView dataGridView; + private Button buttonCancel; + private Button buttonSave; + private DataGridViewTextBoxColumn ID; + private DataGridViewTextBoxColumn ColumnComponentName; + private DataGridViewTextBoxColumn ColumnCount; } } \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormDish.cs b/FoodOrders/FoodOrders/FormDish.cs index 03a5f08..1f02fd2 100644 --- a/FoodOrders/FoodOrders/FormDish.cs +++ b/FoodOrders/FoodOrders/FormDish.cs @@ -1,65 +1,178 @@ -using Microsoft.Extensions.Logging; +using FoodOrders; +using FoodOrdersContracts.BindingModels; using FoodOrdersContracts.BusinessLogicsContracts; using FoodOrdersContracts.SearchModels; -using FoodOrdersContracts.BindingModels; +using FoodOrdersDataModels.Models; +using Microsoft.Extensions.Logging; namespace FoodOrdersView { - public partial class FormComponent : Form + public partial class FormDish : Form { private readonly ILogger _logger; - private readonly IComponentLogic _logic; + private readonly IDishLogic _logic; private int? _id; + private Dictionary _dishComponents; public int Id { set { _id = value; } } - - public FormComponent(ILogger logger, IComponentLogic logic) + public FormDish(ILogger logger, IDishLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; + _dishComponents = new Dictionary(); } - - private void FormComponent_Load(object sender, EventArgs e) + private void FormDish_Load(object sender, EventArgs e) { if (_id.HasValue) { + _logger.LogInformation("Загрузка набор блюд"); try { - _logger.LogInformation("Получение блюда"); - var view = _logic.ReadElement(new ComponentSearchModel + var view = _logic.ReadElement(new DishSearchModel { Id = _id.Value }); if (view != null) { - textBoxName.Text = view.ComponentName; - textBoxCost.Text = view.Cost.ToString(); + textBoxName.Text = view.DishName; + textBoxPrice.Text = view.Price.ToString(); + _dishComponents = view.DishComponents ?? new Dictionary(); + LoadData(); } } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения блюда"); + _logger.LogError(ex, "Ошибка загрузки набор блюд"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } - + private void LoadData() + { + _logger.LogInformation("Загрузка Блюдо набор блюд"); + try + { + if (_dishComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var sc in _dishComponents) + { + dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.ComponentName, sc.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception 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(FormDishComponents)); + if (service is FormDishComponents form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового блюда: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + if (_dishComponents.ContainsKey(form.Id)) + { + _dishComponents[form.Id] = (form.ComponentModel, + form.Count); + } + else + { + _dishComponents.Add(form.Id, (form.ComponentModel, + form.Count)); + } + LoadData(); + } + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormDishComponents)); + if (service is FormDishComponents form) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _dishComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение блюда: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); + _dishComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } + } + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление блюда: { ComponentName} - { Count} ", + dataGridView.SelectedRows[0].Cells[1].Value); _dishComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } private void ButtonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxName.Text)) { - MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - _logger.LogInformation("Сохранение блюда"); + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + if (_dishComponents == null || _dishComponents.Count == 0) + { + MessageBox.Show("Заполните Блюда", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение набор блюд"); try { - var model = new ComponentBindingModel + var model = new DishBindingModel { Id = _id ?? 0, - ComponentName = textBoxName.Text, - Cost = Convert.ToDouble(textBoxCost.Text) + DishName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + DishComponents = _dishComponents }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) @@ -72,16 +185,23 @@ namespace FoodOrdersView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка сохранения блюда"); + _logger.LogError(ex, "Ошибка сохранения набор блюд"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void ButtonCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); } - + private double CalcPrice() + { + double price = 0; + foreach (var elem in _dishComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } } } diff --git a/FoodOrders/FoodOrders/FormDish.resx b/FoodOrders/FoodOrders/FormDish.resx index f298a7b..8e6d533 100644 --- a/FoodOrders/FoodOrders/FormDish.resx +++ b/FoodOrders/FoodOrders/FormDish.resx @@ -57,4 +57,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs b/FoodOrders/FoodOrders/FormDishComponents.Designer.cs similarity index 100% rename from FoodOrders/FoodOrders/FormSetOfDishesComponents.Designer.cs rename to FoodOrders/FoodOrders/FormDishComponents.Designer.cs diff --git a/FoodOrders/FoodOrders/FormSetOfDishesComponents.cs b/FoodOrders/FoodOrders/FormDishComponents.cs similarity index 100% rename from FoodOrders/FoodOrders/FormSetOfDishesComponents.cs rename to FoodOrders/FoodOrders/FormDishComponents.cs diff --git a/FoodOrders/FoodOrders/FormSetOfDishes.resx b/FoodOrders/FoodOrders/FormDishComponents.resx similarity index 83% rename from FoodOrders/FoodOrders/FormSetOfDishes.resx rename to FoodOrders/FoodOrders/FormDishComponents.resx index 8e6d533..f298a7b 100644 --- a/FoodOrders/FoodOrders/FormSetOfDishes.resx +++ b/FoodOrders/FoodOrders/FormDishComponents.resx @@ -57,13 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - - - True - \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormDishes.Designer.cs b/FoodOrders/FoodOrders/FormDishes.Designer.cs index db6eaf1..7a87f80 100644 --- a/FoodOrders/FoodOrders/FormDishes.Designer.cs +++ b/FoodOrders/FoodOrders/FormDishes.Designer.cs @@ -1,6 +1,6 @@ namespace FoodOrdersView { - partial class FormComponents + partial class FormDishes { /// /// Required designer variable. @@ -28,58 +28,14 @@ /// private void InitializeComponent() { + this.dataGridView = new System.Windows.Forms.DataGridView(); 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(); - this.dataGridView = new System.Windows.Forms.DataGridView(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // - // buttonUpdate - // - this.buttonUpdate.Location = new System.Drawing.Point(432, 186); - this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonUpdate.Name = "buttonUpdate"; - this.buttonUpdate.Size = new System.Drawing.Size(130, 22); - this.buttonUpdate.TabIndex = 9; - this.buttonUpdate.Text = "Обновить"; - this.buttonUpdate.UseVisualStyleBackColor = true; - this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); - // - // buttonDelete - // - this.buttonDelete.Location = new System.Drawing.Point(432, 160); - this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonDelete.Name = "buttonDelete"; - this.buttonDelete.Size = new System.Drawing.Size(130, 22); - this.buttonDelete.TabIndex = 8; - this.buttonDelete.Text = "Удалить"; - this.buttonDelete.UseVisualStyleBackColor = true; - this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); - // - // buttonEdit - // - this.buttonEdit.Location = new System.Drawing.Point(432, 134); - this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonEdit.Name = "buttonEdit"; - this.buttonEdit.Size = new System.Drawing.Size(130, 22); - this.buttonEdit.TabIndex = 7; - this.buttonEdit.Text = "Изменить"; - this.buttonEdit.UseVisualStyleBackColor = true; - this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click); - // - // buttonAdd - // - this.buttonAdd.Location = new System.Drawing.Point(432, 108); - this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(130, 22); - this.buttonAdd.TabIndex = 6; - this.buttonAdd.Text = "Добавить"; - this.buttonAdd.UseVisualStyleBackColor = true; - this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); - // // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; @@ -90,22 +46,66 @@ this.dataGridView.Name = "dataGridView"; this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(426, 348); - this.dataGridView.TabIndex = 5; + this.dataGridView.Size = new System.Drawing.Size(426, 345); + this.dataGridView.TabIndex = 10; // - // FormComponents + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(432, 183); + this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(130, 22); + this.buttonUpdate.TabIndex = 14; + this.buttonUpdate.Text = "Обновить"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdate_Click); + // + // buttonDelete + // + this.buttonDelete.Location = new System.Drawing.Point(432, 157); + this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(130, 22); + this.buttonDelete.TabIndex = 13; + this.buttonDelete.Text = "Удалить"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click); + // + // buttonEdit + // + this.buttonEdit.Location = new System.Drawing.Point(432, 131); + this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonEdit.Name = "buttonEdit"; + this.buttonEdit.Size = new System.Drawing.Size(130, 22); + this.buttonEdit.TabIndex = 12; + this.buttonEdit.Text = "Изменить"; + this.buttonEdit.UseVisualStyleBackColor = true; + this.buttonEdit.Click += new System.EventHandler(this.ButtonEdit_Click); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(432, 105); + this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(130, 22); + this.buttonAdd.TabIndex = 11; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // FormDishes // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(571, 348); + this.ClientSize = new System.Drawing.Size(570, 345); this.Controls.Add(this.dataGridView); this.Controls.Add(this.buttonUpdate); this.Controls.Add(this.buttonDelete); this.Controls.Add(this.buttonEdit); this.Controls.Add(this.buttonAdd); - this.Name = "FormComponents"; - this.Text = "Блюда"; - this.Load += new System.EventHandler(this.FormComponents_Load); + this.Name = "FormDishes"; + this.Text = "Список набор блюд"; + this.Load += new System.EventHandler(this.FormDocuments_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); @@ -113,10 +113,10 @@ #endregion + private DataGridView dataGridView; private Button buttonUpdate; private Button buttonDelete; private Button buttonEdit; private Button buttonAdd; - private DataGridView dataGridView; } } \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormDishes.cs b/FoodOrders/FoodOrders/FormDishes.cs index 5b67403..3b85705 100644 --- a/FoodOrders/FoodOrders/FormDishes.cs +++ b/FoodOrders/FoodOrders/FormDishes.cs @@ -5,17 +5,18 @@ using Microsoft.Extensions.Logging; namespace FoodOrdersView { - public partial class FormComponents : Form + public partial class FormDishes : Form { private readonly ILogger _logger; - private readonly IComponentLogic _logic; - public FormComponents(ILogger logger, IComponentLogic logic) + private readonly IDishLogic _logic; + public FormDishes(ILogger logger, IDishLogic logic) { InitializeComponent(); _logger = logger; _logic = logic; } - private void FormComponents_Load(object sender, EventArgs e) + + private void FormDocuments_Load(object sender, EventArgs e) { LoadData(); } @@ -28,21 +29,22 @@ namespace FoodOrdersView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["DishName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["DishComponents"].Visible = false; } - _logger.LogInformation("Загрузка Блюд"); + _logger.LogInformation("Загрузка набор блюд"); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка загрузки Блюд"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + _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(FormComponent)); - if (service is FormComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormDish)); + if (service is FormDish form) { if (form.ShowDialog() == DialogResult.OK) { @@ -50,12 +52,13 @@ namespace FoodOrdersView } } } - private void ButtonUpd_Click(object sender, EventArgs e) + + private void ButtonEdit_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); - if (service is FormComponent form) + var service = Program.ServiceProvider?.GetService(typeof(FormDish)); + if (service is FormDish form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (form.ShowDialog() == DialogResult.OK) @@ -65,17 +68,18 @@ namespace FoodOrdersView } } } - private void ButtonDel_Click(object sender, EventArgs e) + + private void ButtonDelete_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { 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 ComponentBindingModel + if (!_logic.Delete(new DishBindingModel { Id = id })) @@ -86,13 +90,14 @@ namespace FoodOrdersView } catch (Exception ex) { - _logger.LogError(ex, "Ошибка удаления блюда"); + _logger.LogError(ex, "Ошибка удаления набор блюд"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } - private void ButtonRef_Click(object sender, EventArgs e) + + private void ButtonUpdate_Click(object sender, EventArgs e) { LoadData(); } diff --git a/FoodOrders/FoodOrders/FormMain.cs b/FoodOrders/FoodOrders/FormMain.cs index 4c471e2..f36f6b2 100644 --- a/FoodOrders/FoodOrders/FormMain.cs +++ b/FoodOrders/FoodOrders/FormMain.cs @@ -50,8 +50,8 @@ namespace FoodOrdersView } private void DishToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormListDish)); - if (service is FormListDish form) + var service = Program.ServiceProvider?.GetService(typeof(FormDishes)); + if (service is FormDishes form) { form.ShowDialog(); } diff --git a/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs b/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs deleted file mode 100644 index 4c0256c..0000000 --- a/FoodOrders/FoodOrders/FormSetOfDishes.Designer.cs +++ /dev/null @@ -1,246 +0,0 @@ -namespace FoodOrdersView -{ - partial class FormDish - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer Components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (Components != null)) - { - Components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textBoxPrice = new System.Windows.Forms.TextBox(); - this.textBoxName = new System.Windows.Forms.TextBox(); - this.labelPrice = new System.Windows.Forms.Label(); - this.labelName = new System.Windows.Forms.Label(); - this.groupBoxComponents = new System.Windows.Forms.GroupBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSave = 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(); - this.dataGridView = new System.Windows.Forms.DataGridView(); - this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnComponentName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.groupBoxComponents.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); - // - // textBoxPrice - // - this.textBoxPrice.Location = new System.Drawing.Point(90, 36); - this.textBoxPrice.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.textBoxPrice.Name = "textBoxPrice"; - this.textBoxPrice.Size = new System.Drawing.Size(138, 23); - this.textBoxPrice.TabIndex = 7; - // - // textBoxName - // - this.textBoxName.Location = new System.Drawing.Point(90, 11); - this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(276, 23); - this.textBoxName.TabIndex = 6; - // - // labelPrice - // - this.labelPrice.AutoSize = true; - this.labelPrice.Location = new System.Drawing.Point(14, 41); - this.labelPrice.Name = "labelPrice"; - this.labelPrice.Size = new System.Drawing.Size(70, 15); - this.labelPrice.TabIndex = 5; - this.labelPrice.Text = "Стоимость:"; - // - // labelName - // - this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(14, 14); - this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(62, 15); - this.labelName.TabIndex = 4; - this.labelName.Text = "Название:"; - // - // groupBoxComponents - // - this.groupBoxComponents.Controls.Add(this.buttonCancel); - this.groupBoxComponents.Controls.Add(this.buttonSave); - this.groupBoxComponents.Controls.Add(this.buttonUpdate); - this.groupBoxComponents.Controls.Add(this.buttonDelete); - this.groupBoxComponents.Controls.Add(this.buttonEdit); - this.groupBoxComponents.Controls.Add(this.buttonAdd); - this.groupBoxComponents.Controls.Add(this.dataGridView); - this.groupBoxComponents.Dock = System.Windows.Forms.DockStyle.Bottom; - this.groupBoxComponents.Location = new System.Drawing.Point(0, 70); - this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBoxComponents.Name = "groupBoxComponents"; - this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBoxComponents.Size = new System.Drawing.Size(592, 206); - this.groupBoxComponents.TabIndex = 8; - this.groupBoxComponents.TabStop = false; - this.groupBoxComponents.Text = "Компоненты"; - // - // buttonCancel - // - this.buttonCancel.Location = new System.Drawing.Point(504, 176); - this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(79, 22); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); - // - // buttonSave - // - this.buttonSave.Location = new System.Drawing.Point(504, 150); - this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(79, 22); - this.buttonSave.TabIndex = 5; - this.buttonSave.Text = "Сохранить"; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); - // - // buttonUpdate - // - this.buttonUpdate.Location = new System.Drawing.Point(504, 98); - this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonUpdate.Name = "buttonUpdate"; - this.buttonUpdate.Size = new System.Drawing.Size(79, 22); - this.buttonUpdate.TabIndex = 4; - this.buttonUpdate.Text = "Обновить"; - this.buttonUpdate.UseVisualStyleBackColor = true; - this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); - // - // buttonDelete - // - this.buttonDelete.Location = new System.Drawing.Point(504, 72); - this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonDelete.Name = "buttonDelete"; - this.buttonDelete.Size = new System.Drawing.Size(79, 22); - this.buttonDelete.TabIndex = 3; - this.buttonDelete.Text = "Удалить"; - this.buttonDelete.UseVisualStyleBackColor = true; - this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click); - // - // buttonEdit - // - this.buttonEdit.Location = new System.Drawing.Point(504, 46); - this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonEdit.Name = "buttonEdit"; - this.buttonEdit.Size = new System.Drawing.Size(79, 22); - this.buttonEdit.TabIndex = 2; - this.buttonEdit.Text = "Изменить"; - this.buttonEdit.UseVisualStyleBackColor = true; - this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click); - // - // buttonAdd - // - this.buttonAdd.Location = new System.Drawing.Point(504, 20); - this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(79, 22); - this.buttonAdd.TabIndex = 1; - this.buttonAdd.Text = "Добавить"; - this.buttonAdd.UseVisualStyleBackColor = true; - this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); - // - // dataGridView - // - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.ID, - this.ColumnComponentName, - this.ColumnCount}); - 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.RowHeadersWidth = 51; - this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(493, 182); - this.dataGridView.TabIndex = 0; - // - // ID - // - this.ID.HeaderText = "ID"; - this.ID.MinimumWidth = 6; - this.ID.Name = "ID"; - this.ID.Visible = false; - this.ID.Width = 125; - // - // ColumnComponentName - // - this.ColumnComponentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.ColumnComponentName.HeaderText = "Блюдо"; - this.ColumnComponentName.MinimumWidth = 6; - this.ColumnComponentName.Name = "ColumnComponentName"; - this.ColumnComponentName.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.ColumnComponentName.Width = 312; - // - // ColumnCount - // - this.ColumnCount.HeaderText = "Количество"; - this.ColumnCount.MinimumWidth = 6; - this.ColumnCount.Name = "ColumnCount"; - this.ColumnCount.Width = 125; - // - // FormDish - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 276); - this.Controls.Add(this.groupBoxComponents); - this.Controls.Add(this.textBoxPrice); - this.Controls.Add(this.textBoxName); - this.Controls.Add(this.labelPrice); - this.Controls.Add(this.labelName); - this.Name = "FormDish"; - this.Text = "Набор блюд"; - this.Load += new System.EventHandler(this.FormDish_Load); - this.groupBoxComponents.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private TextBox textBoxPrice; - private TextBox textBoxName; - private Label labelPrice; - private Label labelName; - private GroupBox groupBoxComponents; - private Button buttonUpdate; - private Button buttonDelete; - private Button buttonEdit; - private Button buttonAdd; - private DataGridView dataGridView; - private Button buttonCancel; - private Button buttonSave; - private DataGridViewTextBoxColumn ID; - private DataGridViewTextBoxColumn ColumnComponentName; - private DataGridViewTextBoxColumn ColumnCount; - } -} \ No newline at end of file diff --git a/FoodOrders/FoodOrders/FormSetOfDishes.cs b/FoodOrders/FoodOrders/FormSetOfDishes.cs deleted file mode 100644 index 1f02fd2..0000000 --- a/FoodOrders/FoodOrders/FormSetOfDishes.cs +++ /dev/null @@ -1,207 +0,0 @@ -using FoodOrders; -using FoodOrdersContracts.BindingModels; -using FoodOrdersContracts.BusinessLogicsContracts; -using FoodOrdersContracts.SearchModels; -using FoodOrdersDataModels.Models; -using Microsoft.Extensions.Logging; - -namespace FoodOrdersView -{ - public partial class FormDish : Form - { - private readonly ILogger _logger; - private readonly IDishLogic _logic; - private int? _id; - private Dictionary _dishComponents; - public int Id { set { _id = value; } } - public FormDish(ILogger logger, IDishLogic logic) - { - InitializeComponent(); - _logger = logger; - _logic = logic; - _dishComponents = new Dictionary(); - } - private void FormDish_Load(object sender, EventArgs e) - { - if (_id.HasValue) - { - _logger.LogInformation("Загрузка набор блюд"); - try - { - var view = _logic.ReadElement(new DishSearchModel - { - Id = _id.Value - }); - if (view != null) - { - textBoxName.Text = view.DishName; - textBoxPrice.Text = view.Price.ToString(); - _dishComponents = view.DishComponents ?? new Dictionary(); - LoadData(); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки набор блюд"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void LoadData() - { - _logger.LogInformation("Загрузка Блюдо набор блюд"); - try - { - if (_dishComponents != null) - { - dataGridView.Rows.Clear(); - foreach (var sc in _dishComponents) - { - dataGridView.Rows.Add(new object[] { sc.Key, sc.Value.Item1.ComponentName, sc.Value.Item2 }); - } - textBoxPrice.Text = CalcPrice().ToString(); - } - } - catch (Exception 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(FormDishComponents)); - if (service is FormDishComponents form) - { - if (form.ShowDialog() == DialogResult.OK) - { - if (form.ComponentModel == null) - { - return; - } - _logger.LogInformation("Добавление нового блюда: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); - if (_dishComponents.ContainsKey(form.Id)) - { - _dishComponents[form.Id] = (form.ComponentModel, - form.Count); - } - else - { - _dishComponents.Add(form.Id, (form.ComponentModel, - form.Count)); - } - LoadData(); - } - } - } - private void ButtonUpd_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - var service = Program.ServiceProvider?.GetService(typeof(FormDishComponents)); - if (service is FormDishComponents form) - { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); - form.Id = id; - form.Count = _dishComponents[id].Item2; - if (form.ShowDialog() == DialogResult.OK) - { - if (form.ComponentModel == null) - { - return; - } - _logger.LogInformation("Изменение блюда: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); - _dishComponents[form.Id] = (form.ComponentModel, form.Count); - LoadData(); - } - } - } - } - private void ButtonDel_Click(object sender, EventArgs e) - { - if (dataGridView.SelectedRows.Count == 1) - { - if (MessageBox.Show("Удалить запись?", "Вопрос", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - try - { - _logger.LogInformation("Удаление блюда: { ComponentName} - { Count} ", - dataGridView.SelectedRows[0].Cells[1].Value); _dishComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - LoadData(); - } - } - } - private void ButtonRef_Click(object sender, EventArgs e) - { - LoadData(); - } - private void ButtonSave_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(textBoxName.Text)) - { - MessageBox.Show("Заполните название", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - if (string.IsNullOrEmpty(textBoxPrice.Text)) - { - MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - return; - } - if (_dishComponents == null || _dishComponents.Count == 0) - { - MessageBox.Show("Заполните Блюда", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - _logger.LogInformation("Сохранение набор блюд"); - try - { - var model = new DishBindingModel - { - Id = _id ?? 0, - DishName = textBoxName.Text, - Price = Convert.ToDouble(textBoxPrice.Text), - DishComponents = _dishComponents - }; - var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); - DialogResult = DialogResult.OK; - Close(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка сохранения набор блюд"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void ButtonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - private double CalcPrice() - { - double price = 0; - foreach (var elem in _dishComponents) - { - price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); - } - return Math.Round(price * 1.1, 2); - } - } -} diff --git a/FoodOrders/FoodOrders/Program.cs b/FoodOrders/FoodOrders/Program.cs index 8597c4a..8ab0839 100644 --- a/FoodOrders/FoodOrders/Program.cs +++ b/FoodOrders/FoodOrders/Program.cs @@ -49,7 +49,7 @@ namespace FoodOrders services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file -- 2.25.1 From fbe5c946829f24ba9aca872104c482eab5036da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Feb 2023 10:42:04 +0400 Subject: [PATCH 08/12] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=20=D0=BF=D0=B0=D0=BF=D0=BA?= =?UTF-8?q?=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FoodOrders/FoodOrdersDataModels/{ => Enums}/OrderStatus.cs | 0 FoodOrders/FoodOrdersDataModels/{ => Models}/IComponentModel.cs | 0 FoodOrders/FoodOrdersDataModels/{ => Models}/IDishModel.cs | 0 FoodOrders/FoodOrdersDataModels/{ => Models}/IOrderModel.cs | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename FoodOrders/FoodOrdersDataModels/{ => Enums}/OrderStatus.cs (100%) rename FoodOrders/FoodOrdersDataModels/{ => Models}/IComponentModel.cs (100%) rename FoodOrders/FoodOrdersDataModels/{ => Models}/IDishModel.cs (100%) rename FoodOrders/FoodOrdersDataModels/{ => Models}/IOrderModel.cs (100%) diff --git a/FoodOrders/FoodOrdersDataModels/OrderStatus.cs b/FoodOrders/FoodOrdersDataModels/Enums/OrderStatus.cs similarity index 100% rename from FoodOrders/FoodOrdersDataModels/OrderStatus.cs rename to FoodOrders/FoodOrdersDataModels/Enums/OrderStatus.cs diff --git a/FoodOrders/FoodOrdersDataModels/IComponentModel.cs b/FoodOrders/FoodOrdersDataModels/Models/IComponentModel.cs similarity index 100% rename from FoodOrders/FoodOrdersDataModels/IComponentModel.cs rename to FoodOrders/FoodOrdersDataModels/Models/IComponentModel.cs diff --git a/FoodOrders/FoodOrdersDataModels/IDishModel.cs b/FoodOrders/FoodOrdersDataModels/Models/IDishModel.cs similarity index 100% rename from FoodOrders/FoodOrdersDataModels/IDishModel.cs rename to FoodOrders/FoodOrdersDataModels/Models/IDishModel.cs diff --git a/FoodOrders/FoodOrdersDataModels/IOrderModel.cs b/FoodOrders/FoodOrdersDataModels/Models/IOrderModel.cs similarity index 100% rename from FoodOrders/FoodOrdersDataModels/IOrderModel.cs rename to FoodOrders/FoodOrdersDataModels/Models/IOrderModel.cs -- 2.25.1 From 280db9d6e361e867fdb3b3840486ae790cbde641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Feb 2023 13:10:24 +0400 Subject: [PATCH 09/12] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20LabWork01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FoodOrders/FoodOrders/FormCreateOrder.cs | 1 - FoodOrders/FoodOrders/FormMain.cs | 3 --- .../BusinessLogics/OrderLogic.cs | 26 ++++++++++++------ .../BindingModels/OrderBindingModel.cs | 1 - .../Implements/OrderStorage.cs | 27 ++++++++++++++----- .../FoodOrdersListImplement/Models/Order.cs | 8 ------ 6 files changed, 39 insertions(+), 27 deletions(-) diff --git a/FoodOrders/FoodOrders/FormCreateOrder.cs b/FoodOrders/FoodOrders/FormCreateOrder.cs index 554785e..14654f4 100644 --- a/FoodOrders/FoodOrders/FormCreateOrder.cs +++ b/FoodOrders/FoodOrders/FormCreateOrder.cs @@ -88,7 +88,6 @@ namespace FoodOrdersView var operationResult = _logicO.CreateOrder(new OrderBindingModel { DishId = Convert.ToInt32(comboBoxDish.SelectedValue), - DishName = comboBoxDish.Text, Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); diff --git a/FoodOrders/FoodOrders/FormMain.cs b/FoodOrders/FoodOrders/FormMain.cs index f36f6b2..9335ecb 100644 --- a/FoodOrders/FoodOrders/FormMain.cs +++ b/FoodOrders/FoodOrders/FormMain.cs @@ -77,7 +77,6 @@ namespace FoodOrdersView { Id = id, DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), - DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -108,7 +107,6 @@ namespace FoodOrdersView { Id = id, DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), - DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), @@ -139,7 +137,6 @@ namespace FoodOrdersView { Id = id, DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), - DishName = dataGridView.SelectedRows[0].Cells["DishName"].Value.ToString(), Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), diff --git a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs index c63cd43..43a2dfa 100644 --- a/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/FoodOrders/FoodOrdersBusinessLogic/BusinessLogics/OrderLogic.cs @@ -21,8 +21,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics public List? ReadList(OrderSearchModel? model) { _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{Id}", model?.Id); - var list = model == null ? _orderStorage.GetFullList() : - _orderStorage.GetFilteredList(model); + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); @@ -93,18 +92,29 @@ namespace FoodOrdersBusinessLogic.BusinessLogics //??? public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) { - CheckModel(model); - if (model.Status + 1 != newStatus) + var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); + if (viewModel == null) { - _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect."); + throw new ArgumentNullException(nameof(model)); + } + if (viewModel.Status + 1 != newStatus) + { + _logger.LogWarning("Change status operation failed"); return false; } model.Status = newStatus; - if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; + if (model.Status == OrderStatus.Готов) + { + model.DateImplement = DateTime.Now; + } + else + { + model.DateImplement = viewModel.DateImplement; + } + CheckModel(model); if (_orderStorage.Update(model) == null) { - model.Status--; - _logger.LogWarning("Update operation failed"); + _logger.LogWarning("Change status operation failed"); return false; } return true; diff --git a/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs b/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs index 3da89d2..df1918a 100644 --- a/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs +++ b/FoodOrders/FoodOrdersContracts/BindingModels/OrderBindingModel.cs @@ -7,7 +7,6 @@ namespace FoodOrdersContracts.BindingModels { public int Id { get; set; } public int DishId { get; set; } - public string DishName { get; set; } = string.Empty; public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs index 234a6e6..fbb7cd0 100644 --- a/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs +++ b/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs @@ -23,7 +23,7 @@ namespace FoodOrdersListImplement.Implements var result = new List(); foreach (var order in _source.Orders) { - result.Add(order.GetViewModel); + result.Add(GetViewModel(order)); } return result; } @@ -38,7 +38,7 @@ namespace FoodOrdersListImplement.Implements { if (order.Id == model.Id) { - result.Add(order.GetViewModel); + result.Add(GetViewModel(order)); } } return result; @@ -54,11 +54,26 @@ namespace FoodOrdersListImplement.Implements { if (model.Id.HasValue && order.Id == model.Id) { - return order.GetViewModel; + return GetViewModel(order); } } return null; } + + private OrderViewModel GetViewModel(Order order) + { + var viewModel = order.GetViewModel; + foreach (var iceCream in _source.Dish) + { + if (iceCream.Id == order.DishId) + { + viewModel.DishName = iceCream.DishName; + break; + } + } + return viewModel; + } + public OrderViewModel? Delete(OrderBindingModel model) { for (int i = 0; i < _source.Orders.Count; ++i) @@ -67,7 +82,7 @@ namespace FoodOrdersListImplement.Implements { var element = _source.Orders[i]; _source.Orders.RemoveAt(i); - return element.GetViewModel; + return GetViewModel(element); } } return null; @@ -89,7 +104,7 @@ namespace FoodOrdersListImplement.Implements return null; } _source.Orders.Add(newOrder); - return newOrder.GetViewModel; + return GetViewModel(newOrder); } public OrderViewModel? Update(OrderBindingModel model) @@ -99,7 +114,7 @@ namespace FoodOrdersListImplement.Implements if (order.Id == model.Id) { order.Update(model); - return order.GetViewModel; + return GetViewModel(order); } } return null; diff --git a/FoodOrders/FoodOrdersListImplement/Models/Order.cs b/FoodOrders/FoodOrdersListImplement/Models/Order.cs index 152eb9b..6e34f50 100644 --- a/FoodOrders/FoodOrdersListImplement/Models/Order.cs +++ b/FoodOrders/FoodOrdersListImplement/Models/Order.cs @@ -10,7 +10,6 @@ namespace FoodOrdersListImplement.Models { public int Id { get; private set; } public int DishId { get; private set; } - public string DishName { get; private set; } = string.Empty; public int Count { get; private set; } public double Sum { get; private set; } public OrderStatus Status { get; private set; } @@ -27,7 +26,6 @@ namespace FoodOrdersListImplement.Models { Id = model.Id, DishId = model.DishId, - DishName = model.DishName, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -41,19 +39,13 @@ namespace FoodOrdersListImplement.Models { return; } - DishId = model.DishId; - DishName = model.DishName; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; } public OrderViewModel GetViewModel => new() { Id = Id, DishId = DishId, - DishName = DishName, Count = Count, Sum = Sum, Status = Status, -- 2.25.1 From ee2376de940812af9f3dd0c47e8e72459c57e4d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Feb 2023 15:03:09 +0400 Subject: [PATCH 10/12] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FoodOrdersListImplement/Implements/OrderStorage.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs b/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs index fbb7cd0..c9b2696 100644 --- a/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs +++ b/FoodOrders/FoodOrdersListImplement/Implements/OrderStorage.cs @@ -63,11 +63,11 @@ namespace FoodOrdersListImplement.Implements private OrderViewModel GetViewModel(Order order) { var viewModel = order.GetViewModel; - foreach (var iceCream in _source.Dish) + foreach (var dish in _source.Dish) { - if (iceCream.Id == order.DishId) + if (dish.Id == order.DishId) { - viewModel.DishName = iceCream.DishName; + viewModel.DishName = dish.DishName; break; } } -- 2.25.1 From 3f55cd4ba10a39d38a521fc506d81d088d7f528a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Feb 2023 15:31:20 +0400 Subject: [PATCH 11/12] fix --- FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs b/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs index de316fa..34f541f 100644 --- a/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs +++ b/FoodOrders/FoodOrdersContracts/ViewModels/OrderViewModel.cs @@ -10,7 +10,7 @@ namespace FoodOrdersContracts.ViewModels public int DishId { get; set; } - [DisplayName("Изделие")] + [DisplayName("Набор")] public string DishName { get; set; } = string.Empty; [DisplayName("Количество")] -- 2.25.1 From b0fbd900d3b87b743db175599d7e8a9a3c30a9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sun, 12 Feb 2023 16:26:52 +0400 Subject: [PATCH 12/12] fix --- FoodOrders/FoodOrders/FormComponents.cs | 3 +-- FoodOrders/FoodOrders/FormDish.cs | 3 +-- FoodOrders/FoodOrders/FormDishes.cs | 3 +-- FoodOrders/FoodOrders/FormMain.cs | 4 +--- FoodOrders/FoodOrders/Program.cs | 3 +-- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/FoodOrders/FoodOrders/FormComponents.cs b/FoodOrders/FoodOrders/FormComponents.cs index 5b67403..0f5f54b 100644 --- a/FoodOrders/FoodOrders/FormComponents.cs +++ b/FoodOrders/FoodOrders/FormComponents.cs @@ -1,5 +1,4 @@ -using FoodOrders; -using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BindingModels; using FoodOrdersContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; diff --git a/FoodOrders/FoodOrders/FormDish.cs b/FoodOrders/FoodOrders/FormDish.cs index 1f02fd2..9182364 100644 --- a/FoodOrders/FoodOrders/FormDish.cs +++ b/FoodOrders/FoodOrders/FormDish.cs @@ -1,5 +1,4 @@ -using FoodOrders; -using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BindingModels; using FoodOrdersContracts.BusinessLogicsContracts; using FoodOrdersContracts.SearchModels; using FoodOrdersDataModels.Models; diff --git a/FoodOrders/FoodOrders/FormDishes.cs b/FoodOrders/FoodOrders/FormDishes.cs index 3b85705..8e4458e 100644 --- a/FoodOrders/FoodOrders/FormDishes.cs +++ b/FoodOrders/FoodOrders/FormDishes.cs @@ -1,5 +1,4 @@ -using FoodOrders; -using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BindingModels; using FoodOrdersContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; diff --git a/FoodOrders/FoodOrders/FormMain.cs b/FoodOrders/FoodOrders/FormMain.cs index 9335ecb..2255a8a 100644 --- a/FoodOrders/FoodOrders/FormMain.cs +++ b/FoodOrders/FoodOrders/FormMain.cs @@ -1,8 +1,6 @@ -using FoodOrders; -using FoodOrdersContracts.BindingModels; +using FoodOrdersContracts.BindingModels; using FoodOrdersContracts.BusinessLogicsContracts; using FoodOrdersDataModels.Enums; -using FoodOrdersView; using Microsoft.Extensions.Logging; namespace FoodOrdersView diff --git a/FoodOrders/FoodOrders/Program.cs b/FoodOrders/FoodOrders/Program.cs index 8ab0839..f14ca71 100644 --- a/FoodOrders/FoodOrders/Program.cs +++ b/FoodOrders/FoodOrders/Program.cs @@ -3,11 +3,10 @@ using FoodOrdersContracts.StoragesContracts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; -using FoodOrdersView; using FoodOrdersListImplement.Implements; using FoodOrdersBusinessLogic.BusinessLogics; -namespace FoodOrders +namespace FoodOrdersView { internal static class Program { -- 2.25.1