diff --git a/FlowerShop/FlowerShop.sln b/FlowerShop/FlowerShop.sln
index 8c5e4ad..db9a6f6 100644
--- a/FlowerShop/FlowerShop.sln
+++ b/FlowerShop/FlowerShop.sln
@@ -1,9 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
-VisualStudioVersion = 17.3.32922.545
+VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerShop", "FlowerShop\FlowerShop.csproj", "{1E86CFFF-8817-4A8A-B2CB-36062D27AF78}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowerShop", "FlowerShop\FlowerShop.csproj", "{086CB019-AA3B-425A-87B0-26662D1F201F}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowerShopDataModels", "FlowerShopDataModels\FlowerShopDataModels.csproj", "{FDC31847-CB24-4EBD-8CE5-852ED404CEAE}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowerShopContracts", "FlowerShopContracts\FlowerShopContracts.csproj", "{404B251B-7B48-4648-99B4-7E99EDB05A6C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowerShopBusinessLogic", "FlowerShopBusinessLogic\FlowerShopBusinessLogic.csproj", "{D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerShopListImplement", "FlowerShopListImplement\FlowerShopListImplement.csproj", "{C58840E6-D68D-476E-AB3A-EB13F1740FC8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,15 +19,31 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1E86CFFF-8817-4A8A-B2CB-36062D27AF78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1E86CFFF-8817-4A8A-B2CB-36062D27AF78}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1E86CFFF-8817-4A8A-B2CB-36062D27AF78}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1E86CFFF-8817-4A8A-B2CB-36062D27AF78}.Release|Any CPU.Build.0 = Release|Any CPU
+ {086CB019-AA3B-425A-87B0-26662D1F201F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {086CB019-AA3B-425A-87B0-26662D1F201F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {086CB019-AA3B-425A-87B0-26662D1F201F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {086CB019-AA3B-425A-87B0-26662D1F201F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FDC31847-CB24-4EBD-8CE5-852ED404CEAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FDC31847-CB24-4EBD-8CE5-852ED404CEAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FDC31847-CB24-4EBD-8CE5-852ED404CEAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FDC31847-CB24-4EBD-8CE5-852ED404CEAE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {404B251B-7B48-4648-99B4-7E99EDB05A6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {404B251B-7B48-4648-99B4-7E99EDB05A6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {404B251B-7B48-4648-99B4-7E99EDB05A6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {404B251B-7B48-4648-99B4-7E99EDB05A6C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D8084C04-7B2B-4C8D-A63A-71A3EE1BC065}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C58840E6-D68D-476E-AB3A-EB13F1740FC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C58840E6-D68D-476E-AB3A-EB13F1740FC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C58840E6-D68D-476E-AB3A-EB13F1740FC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C58840E6-D68D-476E-AB3A-EB13F1740FC8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {8063D56F-9779-4946-90F8-9D2D40447C33}
+ SolutionGuid = {87A821F8-2466-463B-AD75-707A196B0AA3}
EndGlobalSection
EndGlobal
diff --git a/FlowerShop/FlowerShop/FlowerShop.csproj b/FlowerShop/FlowerShop/FlowerShop.csproj
index 132c02c..ef0424f 100644
--- a/FlowerShop/FlowerShop/FlowerShop.csproj
+++ b/FlowerShop/FlowerShop/FlowerShop.csproj
@@ -1,9 +1,23 @@
-
+
- net6.0
- enable
+ WinExe
+ net6.0-windows
enable
+ true
+ enable
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormBouquetComponent.Designer.cs b/FlowerShop/FlowerShop/FormBouquetComponent.Designer.cs
new file mode 100644
index 0000000..7ef6205
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormBouquetComponent.Designer.cs
@@ -0,0 +1,126 @@
+namespace FlowerShop
+{
+ partial class FormBouquetComponent
+ {
+ ///
+ /// 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.comboBoxComponent = new System.Windows.Forms.ComboBox();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.labelComponent = new System.Windows.Forms.Label();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // comboBoxComponent
+ //
+ this.comboBoxComponent.FormattingEnabled = true;
+ this.comboBoxComponent.Location = new System.Drawing.Point(104, 6);
+ this.comboBoxComponent.Margin = new System.Windows.Forms.Padding(2);
+ this.comboBoxComponent.Name = "comboBoxComponent";
+ this.comboBoxComponent.Size = new System.Drawing.Size(129, 23);
+ this.comboBoxComponent.TabIndex = 0;
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(104, 32);
+ this.textBoxCount.Margin = new System.Windows.Forms.Padding(2);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(129, 23);
+ this.textBoxCount.TabIndex = 1;
+ //
+ // labelComponent
+ //
+ this.labelComponent.AutoSize = true;
+ this.labelComponent.Location = new System.Drawing.Point(11, 11);
+ this.labelComponent.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.labelComponent.Name = "labelComponent";
+ this.labelComponent.Size = new System.Drawing.Size(69, 15);
+ this.labelComponent.TabIndex = 2;
+ this.labelComponent.Text = "Компонент";
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(11, 34);
+ this.labelCount.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(75, 15);
+ this.labelCount.TabIndex = 3;
+ this.labelCount.Text = "Количество ";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(102, 61);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(2);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(78, 25);
+ this.buttonSave.TabIndex = 4;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(184, 61);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(2);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(78, 25);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отменить";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // FormBouquetComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(273, 97);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.labelComponent);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.comboBoxComponent);
+ this.Margin = new System.Windows.Forms.Padding(2);
+ this.Name = "FormBouquetComponent";
+ this.Text = "Компонент букета";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private ComboBox comboBoxComponent;
+ private TextBox textBoxCount;
+ private Label labelComponent;
+ private Label labelCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormComponent.Designer.cs b/FlowerShop/FlowerShop/FormComponent.Designer.cs
new file mode 100644
index 0000000..b37a218
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormComponent.Designer.cs
@@ -0,0 +1,126 @@
+namespace FlowerShop
+{
+ 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.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.labelName = new System.Windows.Forms.Label();
+ this.labelCost = new System.Windows.Forms.Label();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.textBoxCost = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(135, 73);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(2);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(78, 26);
+ this.buttonSave.TabIndex = 0;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(227, 73);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(2);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(78, 26);
+ this.buttonCancel.TabIndex = 1;
+ this.buttonCancel.Text = "Отменить";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(17, 8);
+ this.labelName.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(59, 15);
+ this.labelName.TabIndex = 2;
+ this.labelName.Text = "Название";
+ //
+ // labelCost
+ //
+ this.labelCost.AutoSize = true;
+ this.labelCost.Location = new System.Drawing.Point(17, 38);
+ this.labelCost.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+ this.labelCost.Name = "labelCost";
+ this.labelCost.Size = new System.Drawing.Size(35, 15);
+ this.labelCost.TabIndex = 3;
+ this.labelCost.Text = "Цена";
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(76, 6);
+ this.textBoxName.Margin = new System.Windows.Forms.Padding(2);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(208, 23);
+ this.textBoxName.TabIndex = 4;
+ //
+ // textBoxCost
+ //
+ this.textBoxCost.Location = new System.Drawing.Point(76, 35);
+ this.textBoxCost.Margin = new System.Windows.Forms.Padding(2);
+ this.textBoxCost.Name = "textBoxCost";
+ this.textBoxCost.Size = new System.Drawing.Size(208, 23);
+ this.textBoxCost.TabIndex = 5;
+ //
+ // FormComponent
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(316, 110);
+ this.Controls.Add(this.textBoxCost);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelCost);
+ this.Controls.Add(this.labelName);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Margin = new System.Windows.Forms.Padding(2);
+ this.Name = "FormComponent";
+ this.Text = "Компонент";
+ this.Load += new System.EventHandler(this.FormComponent_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Button buttonSave;
+ private Button buttonCancel;
+ private Label labelName;
+ private Label labelCost;
+ private TextBox textBoxName;
+ private TextBox textBoxCost;
+ }
+}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormMain.Designer.cs b/FlowerShop/FlowerShop/FormMain.Designer.cs
index f962aca..d5e0186 100644
--- a/FlowerShop/FlowerShop/FormMain.Designer.cs
+++ b/FlowerShop/FlowerShop/FormMain.Designer.cs
@@ -35,9 +35,11 @@
this.buttonPut = new System.Windows.Forms.Button();
this.buttonRefresh = new System.Windows.Forms.Button();
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.guidesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.bouquetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.shopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.buttonSupplyShop = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
@@ -112,7 +114,7 @@
//
this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.справочникиToolStripMenuItem});
+ this.guidesToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Padding = new System.Windows.Forms.Padding(4, 1, 0, 1);
@@ -120,34 +122,53 @@
this.menuStrip.TabIndex = 6;
this.menuStrip.Text = "menuStrip1";
//
- // справочникиToolStripMenuItem
+ // guidesToolStripMenuItem
//
- 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, 22);
- this.справочникиToolStripMenuItem.Text = "Справочники";
+ this.guidesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.componentsToolStripMenuItem,
+ this.bouquetsToolStripMenuItem,
+ this.shopsToolStripMenuItem});
+ this.guidesToolStripMenuItem.Name = "guidesToolStripMenuItem";
+ this.guidesToolStripMenuItem.Size = new System.Drawing.Size(94, 22);
+ this.guidesToolStripMenuItem.Text = "Справочники";
//
- // компонентыToolStripMenuItem
+ // componentsToolStripMenuItem
//
- this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
- this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.компонентыToolStripMenuItem.Text = "Компоненты";
- this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.componentsToolStripMenuItem_Click);
+ this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
+ this.componentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.componentsToolStripMenuItem.Text = "Компоненты";
+ this.componentsToolStripMenuItem.Click += new System.EventHandler(this.componentsToolStripMenuItem_Click);
//
- // изделияToolStripMenuItem
+ // bouquetsToolStripMenuItem
//
- this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
- this.изделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.изделияToolStripMenuItem.Text = "Букеты";
- this.изделияToolStripMenuItem.Click += new System.EventHandler(this.bouquetsToolStripMenuItem_Click);
+ this.bouquetsToolStripMenuItem.Name = "bouquetsToolStripMenuItem";
+ this.bouquetsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.bouquetsToolStripMenuItem.Text = "Букеты";
+ this.bouquetsToolStripMenuItem.Click += new System.EventHandler(this.bouquetsToolStripMenuItem_Click);
+ //
+ // shopsToolStripMenuItem
+ //
+ this.shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
+ this.shopsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.shopsToolStripMenuItem.Text = "Магазины";
+ this.shopsToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click);
+ //
+ // buttonSupplyShop
+ //
+ this.buttonSupplyShop.Location = new System.Drawing.Point(891, 202);
+ this.buttonSupplyShop.Name = "buttonSupplyShop";
+ this.buttonSupplyShop.Size = new System.Drawing.Size(150, 30);
+ this.buttonSupplyShop.TabIndex = 7;
+ this.buttonSupplyShop.Text = "Пополнение магазина";
+ this.buttonSupplyShop.UseVisualStyleBackColor = true;
+ this.buttonSupplyShop.Click += new System.EventHandler(this.buttonSupplyShop_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1071, 401);
+ this.Controls.Add(this.buttonSupplyShop);
this.Controls.Add(this.buttonRefresh);
this.Controls.Add(this.buttonPut);
this.Controls.Add(this.buttonReady);
@@ -176,9 +197,11 @@
private Button buttonPut;
private Button buttonRefresh;
private MenuStrip menuStrip;
- private ToolStripMenuItem справочникиToolStripMenuItem;
- private ToolStripMenuItem компонентыToolStripMenuItem;
- private ToolStripMenuItem изделияToolStripMenuItem;
+ private ToolStripMenuItem guidesToolStripMenuItem;
+ private ToolStripMenuItem componentsToolStripMenuItem;
+ private ToolStripMenuItem bouquetsToolStripMenuItem;
private Button buttonReady;
+ private ToolStripMenuItem shopsToolStripMenuItem;
+ private Button buttonSupplyShop;
}
}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormMain.cs b/FlowerShop/FlowerShop/FormMain.cs
index 63f690d..71b96b4 100644
--- a/FlowerShop/FlowerShop/FormMain.cs
+++ b/FlowerShop/FlowerShop/FormMain.cs
@@ -1,6 +1,5 @@
using FlowerShopContracts.BindingModels;
using FlowerShopContracts.BusinessLogicsContracts;
-using FlowerShopDataModels.Enums;
using Microsoft.Extensions.Logging;
namespace FlowerShop
@@ -154,5 +153,23 @@ namespace FlowerShop
{
LoadData();
}
+
+ private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormShops));
+ if (service is FormShops form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void buttonSupplyShop_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply));
+ if (service is FormShopSupply form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/FlowerShop/FlowerShop/FormShop.Designer.cs b/FlowerShop/FlowerShop/FormShop.Designer.cs
new file mode 100644
index 0000000..c5f88b2
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShop.Designer.cs
@@ -0,0 +1,194 @@
+namespace FlowerShop
+{
+ partial class FormShop
+ {
+ ///
+ /// 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.textBoxAddress = new System.Windows.Forms.TextBox();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.labelAddress = new System.Windows.Forms.Label();
+ this.labelName = new System.Windows.Forms.Label();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnBouquetName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.openDateTimePicker = new System.Windows.Forms.DateTimePicker();
+ this.openDateLabel = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // textBoxAddress
+ //
+ this.textBoxAddress.Location = new System.Drawing.Point(88, 34);
+ this.textBoxAddress.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxAddress.Name = "textBoxAddress";
+ this.textBoxAddress.Size = new System.Drawing.Size(276, 23);
+ this.textBoxAddress.TabIndex = 7;
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(88, 9);
+ 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;
+ //
+ // labelAddress
+ //
+ this.labelAddress.AutoSize = true;
+ this.labelAddress.Location = new System.Drawing.Point(12, 38);
+ this.labelAddress.Name = "labelAddress";
+ this.labelAddress.Size = new System.Drawing.Size(43, 15);
+ this.labelAddress.TabIndex = 5;
+ this.labelAddress.Text = "Адрес:";
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(12, 11);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(62, 15);
+ this.labelName.TabIndex = 4;
+ this.labelName.Text = "Название:";
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColumnId,
+ this.ColumnBouquetName,
+ this.ColumnCount});
+ this.dataGridView.Location = new System.Drawing.Point(12, 99);
+ 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(351, 224);
+ this.dataGridView.TabIndex = 10;
+ //
+ // ColumnId
+ //
+ this.ColumnId.HeaderText = "ID";
+ this.ColumnId.MinimumWidth = 6;
+ this.ColumnId.Name = "ColumnId";
+ this.ColumnId.Visible = false;
+ this.ColumnId.Width = 125;
+ //
+ // ColumnBouquetName
+ //
+ this.ColumnBouquetName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.ColumnBouquetName.HeaderText = "Букет";
+ this.ColumnBouquetName.MinimumWidth = 6;
+ this.ColumnBouquetName.Name = "ColumnBouquetName";
+ //
+ // ColumnCount
+ //
+ this.ColumnCount.HeaderText = "Количество";
+ this.ColumnCount.MinimumWidth = 6;
+ this.ColumnCount.Name = "ColumnCount";
+ this.ColumnCount.Width = 125;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(200, 327);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(136, 31);
+ this.buttonCancel.TabIndex = 12;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(42, 327);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(136, 31);
+ this.buttonSave.TabIndex = 11;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // openDateTimePicker
+ //
+ this.openDateTimePicker.Location = new System.Drawing.Point(108, 62);
+ this.openDateTimePicker.Name = "openDateTimePicker";
+ this.openDateTimePicker.Size = new System.Drawing.Size(255, 23);
+ this.openDateTimePicker.TabIndex = 13;
+ //
+ // openDateLabel
+ //
+ this.openDateLabel.AutoSize = true;
+ this.openDateLabel.Location = new System.Drawing.Point(12, 68);
+ this.openDateLabel.Name = "openDateLabel";
+ this.openDateLabel.Size = new System.Drawing.Size(90, 15);
+ this.openDateLabel.TabIndex = 14;
+ this.openDateLabel.Text = "Дата открытия:";
+ //
+ // FormShop
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(389, 367);
+ this.Controls.Add(this.openDateLabel);
+ this.Controls.Add(this.openDateTimePicker);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.textBoxAddress);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelAddress);
+ this.Controls.Add(this.labelName);
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.Name = "FormShop";
+ this.Text = "Магазин";
+ this.Load += new System.EventHandler(this.FormShop_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private TextBox textBoxAddress;
+ private TextBox textBoxName;
+ private Label labelAddress;
+ private Label labelName;
+ private DataGridView dataGridView;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private DataGridViewTextBoxColumn ColumnId;
+ private DataGridViewTextBoxColumn ColumnBouquetName;
+ private DataGridViewTextBoxColumn ColumnCount;
+ private DateTimePicker openDateTimePicker;
+ private Label openDateLabel;
+ }
+}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormShop.cs b/FlowerShop/FlowerShop/FormShop.cs
new file mode 100644
index 0000000..c9beeb2
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShop.cs
@@ -0,0 +1,126 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.BusinessLogicsContracts;
+using FlowerShopContracts.SearchModels;
+using FlowerShopDataModels.Models;
+using Microsoft.Extensions.Logging;
+
+namespace FlowerShop
+{
+ public partial class FormShop : Form
+ {
+
+ private readonly IShopLogic _logic;
+ private readonly ILogger _logger;
+ private Dictionary _shopBouquets;
+ private int? _id;
+ public int Id { set { _id = value; } }
+
+ public FormShop(ILogger logger, IShopLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _shopBouquets = new();
+ }
+
+ private void FormShop_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Loading shop");
+
+ try
+ {
+ var view = _logic.ReadElement(new ShopSearchModel { Id = _id.Value });
+
+ if (view != null)
+ {
+ textBoxName.Text = view.Name;
+ textBoxAddress.Text = view.Address;
+ openDateTimePicker.Value = view.OpeningDate;
+ _shopBouquets = view.ShopBouquets ?? new Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during loading shop");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void LoadData()
+ {
+ _logger.LogInformation("Loading shop's bouquets");
+
+ try
+ {
+ if (_shopBouquets != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var bouquet in _shopBouquets)
+ {
+ dataGridView.Rows.Add(new object[] { bouquet.Key, bouquet.Value.Item1.BouquetName, bouquet.Value.Item2 });
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during loading shop's bouquets");
+ 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;
+ }
+
+ if (string.IsNullOrEmpty(textBoxAddress.Text))
+ {
+ MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Saving shop");
+
+ try
+ {
+ var model = new ShopBindingModel
+ {
+ Id = _id ?? 0,
+ Name = textBoxName.Text,
+ Address = textBoxAddress.Text,
+ OpeningDate = openDateTimePicker.Value,
+ ShopBouquets = _shopBouquets
+ };
+
+ 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, "Error during saving shop");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/FlowerShop/FlowerShop/FormShop.resx b/FlowerShop/FlowerShop/FormShop.resx
new file mode 100644
index 0000000..325b208
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShop.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/FlowerShop/FlowerShop/FormShopSupply.Designer.cs b/FlowerShop/FlowerShop/FormShopSupply.Designer.cs
new file mode 100644
index 0000000..020c467
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShopSupply.Designer.cs
@@ -0,0 +1,150 @@
+namespace FlowerShop
+{
+ partial class FormShopSupply
+ {
+ ///
+ /// 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.labelShop = new System.Windows.Forms.Label();
+ this.labelBouquet = new System.Windows.Forms.Label();
+ this.labelBouquetsCount = new System.Windows.Forms.Label();
+ this.comboBoxShop = new System.Windows.Forms.ComboBox();
+ this.comboBoxBouquet = new System.Windows.Forms.ComboBox();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // labelShop
+ //
+ this.labelShop.AutoSize = true;
+ this.labelShop.Location = new System.Drawing.Point(23, 14);
+ this.labelShop.Name = "labelShop";
+ this.labelShop.RightToLeft = System.Windows.Forms.RightToLeft.No;
+ this.labelShop.Size = new System.Drawing.Size(57, 15);
+ this.labelShop.TabIndex = 0;
+ this.labelShop.Text = "Магазин:";
+ //
+ // labelBouquet
+ //
+ this.labelBouquet.AutoSize = true;
+ this.labelBouquet.Location = new System.Drawing.Point(23, 54);
+ this.labelBouquet.Name = "labelBouquet";
+ this.labelBouquet.Size = new System.Drawing.Size(40, 15);
+ this.labelBouquet.TabIndex = 1;
+ this.labelBouquet.Text = "Букет:";
+ //
+ // labelBouquetsCount
+ //
+ this.labelBouquetsCount.AutoSize = true;
+ this.labelBouquetsCount.Location = new System.Drawing.Point(23, 92);
+ this.labelBouquetsCount.Name = "labelBouquetsCount";
+ this.labelBouquetsCount.Size = new System.Drawing.Size(75, 15);
+ this.labelBouquetsCount.TabIndex = 2;
+ this.labelBouquetsCount.Text = "Количество:";
+ //
+ // comboBoxShop
+ //
+ this.comboBoxShop.FormattingEnabled = true;
+ this.comboBoxShop.Location = new System.Drawing.Point(130, 14);
+ this.comboBoxShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.comboBoxShop.Name = "comboBoxShop";
+ this.comboBoxShop.Size = new System.Drawing.Size(220, 23);
+ this.comboBoxShop.TabIndex = 3;
+ //
+ // comboBoxBouquet
+ //
+ this.comboBoxBouquet.FormattingEnabled = true;
+ this.comboBoxBouquet.Location = new System.Drawing.Point(130, 52);
+ this.comboBoxBouquet.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.comboBoxBouquet.Name = "comboBoxBouquet";
+ this.comboBoxBouquet.Size = new System.Drawing.Size(220, 23);
+ this.comboBoxBouquet.TabIndex = 4;
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(130, 89);
+ this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(110, 23);
+ this.textBoxCount.TabIndex = 5;
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(288, 137);
+ this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(82, 34);
+ this.buttonCancel.TabIndex = 9;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(200, 137);
+ this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(82, 34);
+ this.buttonSave.TabIndex = 8;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // FormShopSupply
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(382, 182);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.comboBoxBouquet);
+ this.Controls.Add(this.comboBoxShop);
+ this.Controls.Add(this.labelBouquetsCount);
+ this.Controls.Add(this.labelBouquet);
+ this.Controls.Add(this.labelShop);
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.Name = "FormShopSupply";
+ this.Text = "Пополнение магазина";
+ this.Load += new System.EventHandler(this.FormShopSupply_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelShop;
+ private Label labelBouquet;
+ private Label labelBouquetsCount;
+ private ComboBox comboBoxShop;
+ private ComboBox comboBoxBouquet;
+ private TextBox textBoxCount;
+ private Button buttonCancel;
+ private Button buttonSave;
+ }
+}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormShopSupply.cs b/FlowerShop/FlowerShop/FormShopSupply.cs
new file mode 100644
index 0000000..8d93dad
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShopSupply.cs
@@ -0,0 +1,118 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.BusinessLogicsContracts;
+using FlowerShopContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+
+namespace FlowerShop
+{
+ public partial class FormShopSupply : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IBouquetLogic _logicBouquet;
+ private readonly IShopLogic _logicShop;
+
+ public FormShopSupply(ILogger logger, IBouquetLogic logicBouquet, IShopLogic logicShop)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicBouquet = logicBouquet;
+ _logicShop = logicShop;
+ }
+
+ private void FormShopSupply_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Loading bouquets for supplying");
+
+ try
+ {
+ var list = _logicBouquet.ReadList(null);
+ if (list != null)
+ {
+ comboBoxBouquet.DisplayMember = "BouquetName";
+ comboBoxBouquet.ValueMember = "Id";
+ comboBoxBouquet.DataSource = list;
+ comboBoxBouquet.SelectedItem = null;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during loading bouquets for supplying");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ _logger.LogInformation("Loading shops for supplying");
+
+ try
+ {
+ var list = _logicShop.ReadList(null);
+ if (list != null)
+ {
+ comboBoxShop.DisplayMember = "Name";
+ comboBoxShop.ValueMember = "Id";
+ comboBoxShop.DataSource = list;
+ comboBoxShop.SelectedItem = null;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during loading shops for supplying");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (comboBoxBouquet.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите букет", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ if (comboBoxShop.SelectedValue== null)
+ {
+ MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ _logger.LogInformation("Creation of supply");
+
+ try
+ {
+ var operationResult = _logicShop.SupplyBouquets(
+ new ShopSearchModel { Id = Convert.ToInt32(comboBoxShop.SelectedValue), Name = comboBoxShop.Text },
+ new BouquetBindingModel { Id = Convert.ToInt32(comboBoxBouquet.SelectedValue), BouquetName = comboBoxBouquet.Text },
+ Convert.ToInt32(textBoxCount.Text)
+ );
+
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
+ }
+
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during creation of supply");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/FlowerShop/FlowerShop/FormShopSupply.resx b/FlowerShop/FlowerShop/FormShopSupply.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShopSupply.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/FlowerShop/FlowerShop/FormShops.Designer.cs b/FlowerShop/FlowerShop/FormShops.Designer.cs
new file mode 100644
index 0000000..25f541c
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShops.Designer.cs
@@ -0,0 +1,121 @@
+namespace FlowerShop
+{
+ partial class FormShops
+ {
+ ///
+ /// 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.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.Location = new System.Drawing.Point(10, 9);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(491, 320);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(549, 294);
+ this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(133, 33);
+ this.buttonUpdate.TabIndex = 9;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(549, 83);
+ this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(133, 33);
+ this.buttonDelete.TabIndex = 8;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(549, 46);
+ this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(133, 33);
+ this.buttonEdit.TabIndex = 7;
+ this.buttonEdit.Text = "Изменить";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(549, 9);
+ this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(133, 33);
+ this.buttonAdd.TabIndex = 6;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // FormShops
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(700, 338);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonEdit);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.Name = "FormShops";
+ this.Text = "Магазины";
+ this.Load += new System.EventHandler(this.FormShops_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/FlowerShop/FlowerShop/FormShops.cs b/FlowerShop/FlowerShop/FormShops.cs
new file mode 100644
index 0000000..94df965
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShops.cs
@@ -0,0 +1,113 @@
+using FlowerShop;
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+
+namespace FlowerShop
+{
+ public partial class FormShops : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IShopLogic _logic;
+
+ public FormShops(ILogger logger, IShopLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormShops_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["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["ShopBouquets"].Visible = false;
+ }
+
+ _logger.LogInformation("Loading shops");
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during loading shops");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormShop));
+
+ if (service is FormShop 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(FormShop));
+
+ if (service is FormShop 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("Deleting shop");
+
+ try
+ {
+ if (!_logic.Delete(new ShopBindingModel { Id = id }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during deleting shop");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/FlowerShop/FlowerShop/FormShops.resx b/FlowerShop/FlowerShop/FormShops.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormShops.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/FlowerShop/FlowerShop/Program.cs b/FlowerShop/FlowerShop/Program.cs
new file mode 100644
index 0000000..1ffdfe6
--- /dev/null
+++ b/FlowerShop/FlowerShop/Program.cs
@@ -0,0 +1,55 @@
+using FlowerShopContracts.StoragesContracts;
+using Microsoft.Extensions.DependencyInjection;
+using FlowerShopListImplement.Implements;
+using FlowerShopBusinessLogic.BusinessLogics;
+using FlowerShopContracts.BusinessLogicsContracts;
+using NLog.Extensions.Logging;
+using Microsoft.Extensions.Logging;
+using System.Windows.Forms;
+
+namespace FlowerShop
+{
+ internal static class Program
+ {
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ ApplicationConfiguration.Initialize();
+ 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();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ }
+ }
+}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShopBusinessLogic/BusinessLogics/ShopLogic.cs b/FlowerShop/FlowerShopBusinessLogic/BusinessLogics/ShopLogic.cs
new file mode 100644
index 0000000..560f0a8
--- /dev/null
+++ b/FlowerShop/FlowerShopBusinessLogic/BusinessLogics/ShopLogic.cs
@@ -0,0 +1,178 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.BusinessLogicsContracts;
+using FlowerShopContracts.SearchModels;
+using FlowerShopContracts.StoragesContracts;
+using FlowerShopContracts.ViewModels;
+using FlowerShopDataModels.Models;
+using Microsoft.Extensions.Logging;
+
+
+namespace FlowerShopBusinessLogic.BusinessLogics
+{
+ public class ShopLogic : IShopLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IShopStorage _shopStorage;
+
+ public ShopLogic(ILogger logger, IShopStorage shopStorage) {
+ _logger = logger;
+ _shopStorage = shopStorage;
+ }
+
+ public ShopViewModel? ReadElement(ShopSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ _logger.LogInformation("ReadElement. Shop Name:{0}, ID:{1}", model.Name, model.Id);
+
+ var element = _shopStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement. element not found");
+ return null;
+ }
+
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+
+ return element;
+ }
+
+ public List? ReadList(ShopSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Shop Name:{0}, ID:{1} ", model?.Name, model?.Id);
+
+ var list = (model == null) ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
+
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+
+ return list;
+ }
+
+ public bool SupplyBouquets(ShopSearchModel model, IBouquetModel bouquet, int count)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (bouquet == null)
+ {
+ throw new ArgumentNullException(nameof(bouquet));
+ }
+
+ if (count <= 0)
+ {
+ throw new ArgumentNullException("Count of bouquets in supply must be more than 0", nameof(count));
+ }
+
+ var shopElement = _shopStorage.GetElement(model);
+ if (shopElement == null)
+ {
+ _logger.LogWarning("Required shop element not found in storage");
+ return false;
+ }
+
+ _logger.LogInformation("Shop element found. ID: {0}, Name: {1}", shopElement.Id, shopElement.Name);
+
+ if (shopElement.ShopBouquets.TryGetValue(bouquet.Id, out var sameBouquet))
+ {
+ shopElement.ShopBouquets[bouquet.Id] = (bouquet, sameBouquet.Item2 + count);
+ _logger.LogInformation("Same bouquet found by supply. Added {0} of {1} in {2} shop", count, bouquet.BouquetName, shopElement.Name);
+ }
+ else
+ {
+ shopElement.ShopBouquets[bouquet.Id] = (bouquet, count);
+ _logger.LogInformation("New bouquet added by supply. Added {0} of {1} in {2} shop", count, bouquet.BouquetName, shopElement.Name);
+ }
+
+ _shopStorage.Update(new()
+ {
+ Id = shopElement.Id,
+ Name = shopElement.Name,
+ Address = shopElement.Address,
+ OpeningDate = shopElement.OpeningDate,
+ ShopBouquets = shopElement.ShopBouquets
+ });
+
+ return true;
+ }
+
+ public bool Create(ShopBindingModel model)
+ {
+ CheckModel(model);
+
+ if (_shopStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool Update(ShopBindingModel model)
+ {
+ CheckModel(model);
+
+ if (_shopStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ public bool Delete(ShopBindingModel model)
+ {
+ CheckModel(model, false);
+
+ if (_shopStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+
+ return true;
+ }
+
+ private void CheckModel(ShopBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (!withParams)
+ {
+ return;
+ }
+
+ if (string.IsNullOrEmpty(model.Name))
+ {
+ throw new ArgumentNullException("Нет названия магазина!", nameof(model.Name));
+ }
+
+ _logger.LogInformation("Shop. Name: {0}, Address: {1}, ID: {2}", model.Name, model.Address, model.Id);
+
+ var element = _shopStorage.GetElement(new ShopSearchModel
+ {
+ Name = model.Name
+ });
+
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Магазин с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/FlowerShop/FlowerShopContracts/BindingModels/ShopBindingModel.cs b/FlowerShop/FlowerShopContracts/BindingModels/ShopBindingModel.cs
new file mode 100644
index 0000000..783aafe
--- /dev/null
+++ b/FlowerShop/FlowerShopContracts/BindingModels/ShopBindingModel.cs
@@ -0,0 +1,17 @@
+using FlowerShopDataModels.Models;
+
+namespace FlowerShopContracts.BindingModels
+{
+ public class ShopBindingModel : IShopModel
+ {
+ public int Id { get; set; }
+
+ public string Name { get; set; } = string.Empty;
+
+ public string Address { get; set; } = string.Empty;
+
+ public DateTime OpeningDate { get; set; }
+
+ public Dictionary ShopBouquets { get; set; }
+ }
+}
diff --git a/FlowerShop/FlowerShopContracts/BusinessLogicsContracts/IShopLogic.cs b/FlowerShop/FlowerShopContracts/BusinessLogicsContracts/IShopLogic.cs
new file mode 100644
index 0000000..fc1d683
--- /dev/null
+++ b/FlowerShop/FlowerShopContracts/BusinessLogicsContracts/IShopLogic.cs
@@ -0,0 +1,17 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.SearchModels;
+using FlowerShopContracts.ViewModels;
+using FlowerShopDataModels.Models;
+
+namespace FlowerShopContracts.BusinessLogicsContracts
+{
+ public interface IShopLogic
+ {
+ ShopViewModel? ReadElement(ShopSearchModel model);
+ List? ReadList(ShopSearchModel? model);
+ bool Create(ShopBindingModel model);
+ bool Update(ShopBindingModel model);
+ bool Delete(ShopBindingModel model);
+ bool SupplyBouquets(ShopSearchModel model, IBouquetModel bouquet, int count);
+ }
+}
diff --git a/FlowerShop/FlowerShopContracts/SearchModels/ShopSearchModel.cs b/FlowerShop/FlowerShopContracts/SearchModels/ShopSearchModel.cs
new file mode 100644
index 0000000..5b03d1c
--- /dev/null
+++ b/FlowerShop/FlowerShopContracts/SearchModels/ShopSearchModel.cs
@@ -0,0 +1,8 @@
+namespace FlowerShopContracts.SearchModels
+{
+ public class ShopSearchModel
+ {
+ public int? Id { get; set; }
+ public string? Name { get; set; }
+ }
+}
diff --git a/FlowerShop/FlowerShopContracts/StoragesContracts/IShopStorage.cs b/FlowerShop/FlowerShopContracts/StoragesContracts/IShopStorage.cs
new file mode 100644
index 0000000..307e37c
--- /dev/null
+++ b/FlowerShop/FlowerShopContracts/StoragesContracts/IShopStorage.cs
@@ -0,0 +1,16 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.SearchModels;
+using FlowerShopContracts.ViewModels;
+
+namespace FlowerShopContracts.StoragesContracts
+{
+ public interface IShopStorage
+ {
+ ShopViewModel? GetElement(ShopSearchModel model);
+ List GetFullList();
+ List GetFilteredList(ShopSearchModel model);
+ ShopViewModel? Insert(ShopBindingModel model);
+ ShopViewModel? Update(ShopBindingModel model);
+ ShopViewModel? Delete(ShopBindingModel model);
+ }
+}
diff --git a/FlowerShop/FlowerShopContracts/ViewModels/ShopViewModel.cs b/FlowerShop/FlowerShopContracts/ViewModels/ShopViewModel.cs
new file mode 100644
index 0000000..c2330da
--- /dev/null
+++ b/FlowerShop/FlowerShopContracts/ViewModels/ShopViewModel.cs
@@ -0,0 +1,21 @@
+using FlowerShopDataModels.Models;
+using System.ComponentModel;
+
+namespace FlowerShopContracts.ViewModels
+{
+ public class ShopViewModel : IShopModel
+ {
+ public int Id { get; set; }
+
+ [DisplayName("Название магазина")]
+ public string Name { get; set; } = string.Empty;
+
+ [DisplayName("Адрес")]
+ public string Address { get; set; } = string.Empty;
+
+ [DisplayName("Дата открытия")]
+ public DateTime OpeningDate { get; set; }
+
+ public Dictionary ShopBouquets { get; set; } = new();
+ }
+}
diff --git a/FlowerShop/FlowerShopDataModels/Models/IShopModel.cs b/FlowerShop/FlowerShopDataModels/Models/IShopModel.cs
new file mode 100644
index 0000000..e9df4aa
--- /dev/null
+++ b/FlowerShop/FlowerShopDataModels/Models/IShopModel.cs
@@ -0,0 +1,10 @@
+namespace FlowerShopDataModels.Models
+{
+ public interface IShopModel : IId
+ {
+ string Name { get; }
+ string Address { get; }
+ DateTime OpeningDate { get; }
+ Dictionary ShopBouquets { get; }
+ }
+}
diff --git a/FlowerShop/FlowerShopListImplement/DataListSingleton.cs b/FlowerShop/FlowerShopListImplement/DataListSingleton.cs
index 59460c6..e030e40 100644
--- a/FlowerShop/FlowerShopListImplement/DataListSingleton.cs
+++ b/FlowerShop/FlowerShopListImplement/DataListSingleton.cs
@@ -8,12 +8,14 @@ namespace FlowerShopListImplement
public List Components { get; set; }
public List Orders { get; set; }
public List Bouquets { get; set; }
+ public List Shops { get; set; }
private DataListSingleton()
{
Components = new List();
Orders = new List();
Bouquets = new List();
+ Shops = new List();
}
public static DataListSingleton GetInstance()
diff --git a/FlowerShop/FlowerShopListImplement/Implements/ShopStorage.cs b/FlowerShop/FlowerShopListImplement/Implements/ShopStorage.cs
new file mode 100644
index 0000000..ad16fc1
--- /dev/null
+++ b/FlowerShop/FlowerShopListImplement/Implements/ShopStorage.cs
@@ -0,0 +1,121 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.SearchModels;
+using FlowerShopContracts.StoragesContracts;
+using FlowerShopContracts.ViewModels;
+using FlowerShopListImplement.Models;
+
+
+namespace FlowerShopListImplement.Implements
+{
+ public class ShopStorage : IShopStorage
+ {
+ private readonly DataListSingleton _source;
+
+ public ShopStorage()
{
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public ShopViewModel? GetElement(ShopSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
+ {
+ return null;
+ }
+
+ foreach (var shop in _source.Shops)
+ {
+ if ((!string.IsNullOrEmpty(model.Name) && shop.Name == model.Name) || (model.Id.HasValue && shop.Id == model.Id))
+ {
+ return shop.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public List GetFilteredList(ShopSearchModel model)
+ {
+ var result = new List();
+
+ if (string.IsNullOrEmpty(model.Name))
+ {
+ return result;
+ }
+
+ foreach (var shop in _source.Shops)
+ {
+ if (shop.Name.Contains(model.Name))
+ {
+ result.Add(shop.GetViewModel);
+ }
+ }
+
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+
+ foreach (var shop in _source.Shops)
+ {
+ result.Add(shop.GetViewModel);
+ }
+
+ return result;
+ }
+
+ public ShopViewModel? Insert(ShopBindingModel model)
+ {
+ model.Id = 1;
+
+ foreach (var shop in _source.Shops)
+ {
+ if (model.Id <= shop.Id)
+ {
+ model.Id = shop.Id + 1;
+ }
+ }
+
+ var newShop = Shop.Create(model);
+
+ if (newShop == null)
+ {
+ return null;
+ }
+
+ _source.Shops.Add(newShop);
+
+ return newShop.GetViewModel;
+ }
+
+ public ShopViewModel? Update(ShopBindingModel model)
+ {
+ foreach (var shop in _source.Shops)
+ {
+ if (shop.Id == model.Id)
+ {
+ shop.Update(model);
+ return shop.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+
+ public ShopViewModel? Delete(ShopBindingModel model)
+ {
+ for (int i = 0; i < _source.Shops.Count; ++i)
+ {
+ if (_source.Shops[i].Id == model.Id)
+ {
+ var element = _source.Shops[i];
+ _source.Shops.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/FlowerShop/FlowerShopListImplement/Models/Shop.cs b/FlowerShop/FlowerShopListImplement/Models/Shop.cs
new file mode 100644
index 0000000..abbdf34
--- /dev/null
+++ b/FlowerShop/FlowerShopListImplement/Models/Shop.cs
@@ -0,0 +1,57 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.ViewModels;
+using FlowerShopDataModels.Models;
+
+namespace FlowerShopListImplement.Models
+{
+ public class Shop : IShopModel
+ {
+ public int Id { get; private set; }
+
+ public string Name { get; private set; } = string.Empty;
+
+ public string Address { get; private set; } = string.Empty;
+
+ public DateTime OpeningDate { get; private set; }
+
+ public Dictionary ShopBouquets { get; private set; } = new();
+
+ public static Shop? Create(ShopBindingModel model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+
+ return new Shop()
+ {
+ Id = model.Id,
+ Name = model.Name,
+ Address = model.Address,
+ OpeningDate = model.OpeningDate,
+ ShopBouquets = new()
+ };
+ }
+
+ public void Update(ShopBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+
+ Name = model.Name;
+ Address = model.Address;
+ ShopBouquets = model.ShopBouquets;
+ }
+
+ public ShopViewModel GetViewModel => new()
+ {
+ Id = Id,
+ Name = Name,
+ Address = Address,
+ OpeningDate = OpeningDate,
+ ShopBouquets = ShopBouquets
+ };
+ }
+}