diff --git a/.gitignore b/.gitignore
index a2e929e..a02c73a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -477,3 +477,43 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
+# Common IntelliJ Platform excludes
+
+# User specific
+**/.idea/**/workspace.xml
+**/.idea/**/tasks.xml
+**/.idea/shelf/*
+**/.idea/dictionaries
+**/.idea/httpRequests/
+
+# Sensitive or high-churn files
+**/.idea/**/dataSources/
+**/.idea/**/dataSources.ids
+**/.idea/**/dataSources.xml
+**/.idea/**/dataSources.local.xml
+**/.idea/**/sqlDataSources.xml
+**/.idea/**/dynamic.xml
+
+# Rider
+# Rider auto-generates .iml files, and contentModel.xml
+**/.idea/**/*.iml
+**/.idea/**/contentModel.xml
+**/.idea/**/modules.xml
+
+*.suo
+*.user
+.vs/
+[Bb]in/
+[Oo]bj/
+_UpgradeReport_Files/
+[Pp]ackages/
+
+Thumbs.db
+Desktop.ini
+.DS_Store
+
+**/.idea/**
+/.idea/
+.idea/
+.idea/**
+.idea
diff --git a/FurnitureAssembly/FurnitureAssembly.sln b/FurnitureAssembly/FurnitureAssembly.sln
new file mode 100644
index 0000000..7f96c46
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.2.32505.173
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyView", "FurnitureAssembly\FurnitureAssemblyView.csproj", "{7BB0218D-0435-4068-BD9E-054617BB0E24}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyBusinessLogic", "FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj", "{EE08F624-8C6A-4F3F-B44B-E065DC5455A9}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyContracts", "FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj", "{1DE27E8F-792B-4C07-B6F3-1912FFC40ABC}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyListImplement", "FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj", "{79A01852-C965-4720-8003-ACE5D9C22002}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyDataModels", "FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj", "{F9199856-F724-49E7-A159-711AC00A7773}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7BB0218D-0435-4068-BD9E-054617BB0E24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7BB0218D-0435-4068-BD9E-054617BB0E24}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7BB0218D-0435-4068-BD9E-054617BB0E24}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7BB0218D-0435-4068-BD9E-054617BB0E24}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EE08F624-8C6A-4F3F-B44B-E065DC5455A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EE08F624-8C6A-4F3F-B44B-E065DC5455A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EE08F624-8C6A-4F3F-B44B-E065DC5455A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EE08F624-8C6A-4F3F-B44B-E065DC5455A9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1DE27E8F-792B-4C07-B6F3-1912FFC40ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1DE27E8F-792B-4C07-B6F3-1912FFC40ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1DE27E8F-792B-4C07-B6F3-1912FFC40ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1DE27E8F-792B-4C07-B6F3-1912FFC40ABC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {79A01852-C965-4720-8003-ACE5D9C22002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {79A01852-C965-4720-8003-ACE5D9C22002}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {79A01852-C965-4720-8003-ACE5D9C22002}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {79A01852-C965-4720-8003-ACE5D9C22002}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F9199856-F724-49E7-A159-711AC00A7773}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F9199856-F724-49E7-A159-711AC00A7773}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F9199856-F724-49E7-A159-711AC00A7773}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F9199856-F724-49E7-A159-711AC00A7773}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {27DCA94C-C55A-4228-BD85-C3FD7C770981}
+ EndGlobalSection
+EndGlobal
diff --git a/FurnitureAssembly/FurnitureAssembly/ComponentForm.Designer.cs b/FurnitureAssembly/FurnitureAssembly/ComponentForm.Designer.cs
new file mode 100644
index 0000000..da0760d
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/ComponentForm.Designer.cs
@@ -0,0 +1,119 @@
+namespace FurnitureAssembly
+{
+ partial class ComponentForm
+ {
+ ///
+ /// 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(108, 101);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(112, 34);
+ 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(292, 101);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(112, 34);
+ 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(24, 13);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(90, 25);
+ this.labelName.TabIndex = 2;
+ this.labelName.Text = "Название";
+ //
+ // labelCost
+ //
+ this.labelCost.AutoSize = true;
+ this.labelCost.Location = new System.Drawing.Point(24, 59);
+ this.labelCost.Name = "labelCost";
+ this.labelCost.Size = new System.Drawing.Size(53, 25);
+ this.labelCost.TabIndex = 3;
+ this.labelCost.Text = "Цена";
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(108, 10);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(296, 31);
+ this.textBoxName.TabIndex = 4;
+ //
+ // textBoxCost
+ //
+ this.textBoxCost.Location = new System.Drawing.Point(108, 49);
+ this.textBoxCost.Name = "textBoxCost";
+ this.textBoxCost.Size = new System.Drawing.Size(216, 31);
+ this.textBoxCost.TabIndex = 5;
+ //
+ // ComponentForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(435, 156);
+ 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.Name = "ComponentForm";
+ this.Text = "Компонент";
+ this.Load += new System.EventHandler(this.ComponentForm_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/FurnitureAssembly/FurnitureAssembly/ComponentForm.cs b/FurnitureAssembly/FurnitureAssembly/ComponentForm.cs
new file mode 100644
index 0000000..368a076
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/ComponentForm.cs
@@ -0,0 +1,87 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace FurnitureAssembly
+{
+ public partial class ComponentForm : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentLogic _logic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public ComponentForm(ILogger logger, IComponentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void ComponentForm_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();
+ }
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/ComponentForm.resx b/FurnitureAssembly/FurnitureAssembly/ComponentForm.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/ComponentForm.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/FurnitureAssembly/FurnitureAssembly/ComponentsForm.Designer.cs b/FurnitureAssembly/FurnitureAssembly/ComponentsForm.Designer.cs
new file mode 100644
index 0000000..cb4c56e
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/ComponentsForm.Designer.cs
@@ -0,0 +1,116 @@
+namespace FurnitureAssemblyView
+{
+ partial class ComponentsForm
+ {
+ ///
+ /// 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.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonChange = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonUpdate = 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.Location = new System.Drawing.Point(0, 0);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 62;
+ this.dataGridView.RowTemplate.Height = 33;
+ this.dataGridView.Size = new System.Drawing.Size(459, 488);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(480, 25);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(112, 34);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // buttonChange
+ //
+ this.buttonChange.Location = new System.Drawing.Point(481, 67);
+ this.buttonChange.Name = "buttonChange";
+ this.buttonChange.Size = new System.Drawing.Size(112, 34);
+ this.buttonChange.TabIndex = 2;
+ this.buttonChange.Text = "Изменить";
+ this.buttonChange.UseVisualStyleBackColor = true;
+ this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(481, 107);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(112, 34);
+ this.buttonDelete.TabIndex = 3;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(481, 147);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(112, 34);
+ this.buttonUpdate.TabIndex = 4;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
+ //
+ // ComponentsForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(614, 488);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonChange);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "ComponentsForm";
+ this.Text = "Компоненты";
+ this.Load += new System.EventHandler(this.ComponentsForm_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonChange;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/ComponentsForm.cs b/FurnitureAssembly/FurnitureAssembly/ComponentsForm.cs
new file mode 100644
index 0000000..3d1ab9a
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/ComponentsForm.cs
@@ -0,0 +1,118 @@
+using FurnitureAssembly;
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FurnitureAssemblyView
+{
+ public partial class ComponentsForm : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentLogic _logic;
+ public ComponentsForm(ILogger logger, IComponentLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void ComponentsForm_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["ComponentName"].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(ComponentForm));
+ if (service is ComponentForm form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ 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 ComponentBindingModel {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления компонента");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ }
+
+ private void buttonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(ComponentForm));
+ if (service is ComponentForm form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ }
+ }
diff --git a/FurnitureAssembly/FurnitureAssembly/ComponentsForm.resx b/FurnitureAssembly/FurnitureAssembly/ComponentsForm.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/ComponentsForm.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/FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs b/FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs
new file mode 100644
index 0000000..83ebd63
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/Form1.Designer.cs
@@ -0,0 +1,39 @@
+namespace FurnitureAssembly
+{
+ 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/FurnitureAssembly/FurnitureAssembly/Form1.cs b/FurnitureAssembly/FurnitureAssembly/Form1.cs
new file mode 100644
index 0000000..c186dd4
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/Form1.cs
@@ -0,0 +1,10 @@
+namespace FurnitureAssembly
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/Form1.resx b/FurnitureAssembly/FurnitureAssembly/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj
new file mode 100644
index 0000000..b57c89e
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj
@@ -0,0 +1,11 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.sln b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.sln
new file mode 100644
index 0000000..531b474
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32210.238
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyView", "FurnitureAssemblyView.csproj", "{459EB9DC-7D0D-46FB-825D-A6C9E3DF0C7A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyContracts", "..\FurnitureAssemblyContracts\FurnitureAssemblyContracts.csproj", "{8E5753AD-9093-4A95-BA85-4A7C382ED5BA}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyBusinessLogic", "..\FurnitureAssemblyBusinessLogic\FurnitureAssemblyBusinessLogic.csproj", "{BA9BCA19-0C5F-41C8-98ED-7AB8D3DF6CA8}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyListImplement", "..\FurnitureAssemblyListImplement\FurnitureAssemblyListImplement.csproj", "{2A965D1B-CA9F-4268-A157-8A7D539FBDD2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyDataModels", "..\FurnitureAssemblyDataModels\FurnitureAssemblyDataModels.csproj", "{2DDAC375-59FB-4E1F-9685-C8839610AB94}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {459EB9DC-7D0D-46FB-825D-A6C9E3DF0C7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {459EB9DC-7D0D-46FB-825D-A6C9E3DF0C7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {459EB9DC-7D0D-46FB-825D-A6C9E3DF0C7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {459EB9DC-7D0D-46FB-825D-A6C9E3DF0C7A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8E5753AD-9093-4A95-BA85-4A7C382ED5BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8E5753AD-9093-4A95-BA85-4A7C382ED5BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8E5753AD-9093-4A95-BA85-4A7C382ED5BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8E5753AD-9093-4A95-BA85-4A7C382ED5BA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BA9BCA19-0C5F-41C8-98ED-7AB8D3DF6CA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BA9BCA19-0C5F-41C8-98ED-7AB8D3DF6CA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BA9BCA19-0C5F-41C8-98ED-7AB8D3DF6CA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BA9BCA19-0C5F-41C8-98ED-7AB8D3DF6CA8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2A965D1B-CA9F-4268-A157-8A7D539FBDD2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2DDAC375-59FB-4E1F-9685-C8839610AB94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2DDAC375-59FB-4E1F-9685-C8839610AB94}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2DDAC375-59FB-4E1F-9685-C8839610AB94}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2DDAC375-59FB-4E1F-9685-C8839610AB94}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {61DCB441-2417-4604-A326-C56B939EDD36}
+ EndGlobalSection
+EndGlobal
diff --git a/FurnitureAssembly/FurnitureAssembly/FurnitureAssemblyView.csproj b/FurnitureAssembly/FurnitureAssembly/FurnitureAssemblyView.csproj
new file mode 100644
index 0000000..122a0d8
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureAssemblyView.csproj
@@ -0,0 +1,24 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.Designer.cs
new file mode 100644
index 0000000..d5cbf04
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.Designer.cs
@@ -0,0 +1,119 @@
+namespace FurnitureAssemblyView
+{
+ partial class FurnitureComponentForm
+ {
+ ///
+ /// 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(148, 10);
+ this.comboBoxComponent.Name = "comboBoxComponent";
+ this.comboBoxComponent.Size = new System.Drawing.Size(182, 33);
+ this.comboBoxComponent.TabIndex = 0;
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(150, 53);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(150, 31);
+ this.textBoxCount.TabIndex = 1;
+ //
+ // labelComponent
+ //
+ this.labelComponent.AutoSize = true;
+ this.labelComponent.Location = new System.Drawing.Point(16, 18);
+ this.labelComponent.Name = "labelComponent";
+ this.labelComponent.Size = new System.Drawing.Size(103, 25);
+ this.labelComponent.TabIndex = 2;
+ this.labelComponent.Text = "Компонент";
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(16, 57);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(112, 25);
+ this.labelCount.TabIndex = 3;
+ this.labelCount.Text = "Количество ";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(75, 99);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(112, 34);
+ 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(206, 99);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(112, 34);
+ this.buttonCancel.TabIndex = 5;
+ this.buttonCancel.Text = "Отменить";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // FurnitureComponentForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(370, 142);
+ 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.Name = "FurnitureComponentForm";
+ 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/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.cs b/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.cs
new file mode 100644
index 0000000..6c62a62
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.cs
@@ -0,0 +1,92 @@
+using FurnitureAssemblyDataModels.Models;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FurnitureAssemblyView
+{
+ public partial class FurnitureComponentForm : Form
+ {
+ private readonly List? _list;
+ public int Id
+ {
+ get
+ {
+ return Convert.ToInt32(comboBoxComponent.SelectedValue);
+ }
+ set
+ {
+ comboBoxComponent.SelectedValue = value;
+ }
+ }
+ public IComponentModel? 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 FurnitureComponentForm(IComponentLogic logic)
+ {
+ InitializeComponent();
+ _list = logic.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxComponent.DisplayMember = "ComponentName";
+ comboBoxComponent.ValueMember = "Id";
+ comboBoxComponent.DataSource = _list;
+ comboBoxComponent.SelectedItem = null;
+ }
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxComponent.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/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.resx b/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureComponentForm.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/FurnitureAssembly/FurnitureAssembly/FurnitureForm.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FurnitureForm.Designer.cs
new file mode 100644
index 0000000..0a4f422
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureForm.Designer.cs
@@ -0,0 +1,221 @@
+namespace FurnitureAssemblyView
+{
+ partial class FurnitureForm
+ {
+ ///
+ /// 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.labelName = new System.Windows.Forms.Label();
+ this.labelPrice = new System.Windows.Forms.Label();
+ this.textBoxName = new System.Windows.Forms.TextBox();
+ this.textBoxPrice = new System.Windows.Forms.TextBox();
+ this.groupBoxComponent = new System.Windows.Forms.GroupBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonChange = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ this.groupBoxComponent.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // labelName
+ //
+ this.labelName.AutoSize = true;
+ this.labelName.Location = new System.Drawing.Point(19, 19);
+ this.labelName.Name = "labelName";
+ this.labelName.Size = new System.Drawing.Size(94, 25);
+ this.labelName.TabIndex = 0;
+ this.labelName.Text = "Название:";
+ //
+ // labelPrice
+ //
+ this.labelPrice.AutoSize = true;
+ this.labelPrice.Location = new System.Drawing.Point(19, 59);
+ this.labelPrice.Name = "labelPrice";
+ this.labelPrice.Size = new System.Drawing.Size(108, 25);
+ this.labelPrice.TabIndex = 1;
+ this.labelPrice.Text = "Стоимость: ";
+ //
+ // textBoxName
+ //
+ this.textBoxName.Location = new System.Drawing.Point(119, 16);
+ this.textBoxName.Name = "textBoxName";
+ this.textBoxName.Size = new System.Drawing.Size(340, 31);
+ this.textBoxName.TabIndex = 2;
+ //
+ // textBoxPrice
+ //
+ this.textBoxPrice.Location = new System.Drawing.Point(119, 53);
+ this.textBoxPrice.Name = "textBoxPrice";
+ this.textBoxPrice.Size = new System.Drawing.Size(150, 31);
+ this.textBoxPrice.TabIndex = 3;
+ //
+ // groupBoxComponent
+ //
+ this.groupBoxComponent.Controls.Add(this.buttonUpdate);
+ this.groupBoxComponent.Controls.Add(this.buttonDelete);
+ this.groupBoxComponent.Controls.Add(this.buttonChange);
+ this.groupBoxComponent.Controls.Add(this.buttonAdd);
+ this.groupBoxComponent.Controls.Add(this.dataGridView);
+ this.groupBoxComponent.Location = new System.Drawing.Point(14, 108);
+ this.groupBoxComponent.Name = "groupBoxComponent";
+ this.groupBoxComponent.Size = new System.Drawing.Size(763, 330);
+ this.groupBoxComponent.TabIndex = 4;
+ this.groupBoxComponent.TabStop = false;
+ this.groupBoxComponent.Text = "Компоненты";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(431, 452);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(112, 34);
+ this.buttonSave.TabIndex = 5;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(562, 454);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(112, 34);
+ this.buttonCancel.TabIndex = 6;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColumnComponent,
+ this.ColumnCount});
+ this.dataGridView.Location = new System.Drawing.Point(25, 30);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 62;
+ this.dataGridView.RowTemplate.Height = 33;
+ this.dataGridView.Size = new System.Drawing.Size(554, 281);
+ this.dataGridView.TabIndex = 0;
+ //
+ // ColumnComponent
+ //
+ this.ColumnComponent.HeaderText = "Компонент";
+ this.ColumnComponent.MinimumWidth = 8;
+ this.ColumnComponent.Name = "ColumnComponent";
+ this.ColumnComponent.Width = 150;
+ //
+ // ColumnCount
+ //
+ this.ColumnCount.HeaderText = "Количество";
+ this.ColumnCount.MinimumWidth = 8;
+ this.ColumnCount.Name = "ColumnCount";
+ this.ColumnCount.Width = 150;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(602, 35);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(112, 34);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // buttonChange
+ //
+ this.buttonChange.Location = new System.Drawing.Point(602, 81);
+ this.buttonChange.Name = "buttonChange";
+ this.buttonChange.Size = new System.Drawing.Size(112, 34);
+ this.buttonChange.TabIndex = 2;
+ this.buttonChange.Text = "Изменить";
+ this.buttonChange.UseVisualStyleBackColor = true;
+ this.buttonChange.Click += new System.EventHandler(this.buttonChange_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(604, 124);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(112, 34);
+ this.buttonDelete.TabIndex = 3;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(604, 164);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(112, 34);
+ this.buttonUpdate.TabIndex = 4;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
+ //
+ // FurnitureForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 495);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.groupBoxComponent);
+ this.Controls.Add(this.textBoxPrice);
+ this.Controls.Add(this.textBoxName);
+ this.Controls.Add(this.labelPrice);
+ this.Controls.Add(this.labelName);
+ this.Name = "FurnitureForm";
+ this.Text = "Изделие";
+ this.Load += new System.EventHandler(this.FurnitureForm_Load);
+ this.groupBoxComponent.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private Label labelName;
+ private Label labelPrice;
+ private TextBox textBoxName;
+ private TextBox textBoxPrice;
+ private GroupBox groupBoxComponent;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonChange;
+ private Button buttonAdd;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn ColumnComponent;
+ private DataGridViewTextBoxColumn ColumnCount;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/FurnitureForm.cs b/FurnitureAssembly/FurnitureAssembly/FurnitureForm.cs
new file mode 100644
index 0000000..a8a1e1c
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureForm.cs
@@ -0,0 +1,229 @@
+using FurnitureAssemblyDataModels.Models;
+using FurnitureAssembly;
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FurnitureAssemblyView
+{
+ public partial class FurnitureForm : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IfurnitureLogic _logic;
+ private int? _id;
+ private Dictionary _furnitureComponents;
+ public int Id { set { _id = value; } }
+ public FurnitureForm(ILogger logger, IfurnitureLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ _furnitureComponents = new Dictionary();
+ }
+
+ private void FurnitureForm_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ _logger.LogInformation("Загрузка изделия");
+ try
+ {
+ var view = _logic.ReadElement(new FurnitureSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.FurnitureName;
+ textBoxPrice.Text = view.Price.ToString();
+ _furnitureComponents = view.FurnitureComponents ?? new
+ Dictionary();
+ LoadData();
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки изделия");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка компонент изделия");
+ try
+ {
+ if (_furnitureComponents != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var pc in _furnitureComponents)
+ {
+ dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.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(FurnitureComponentForm));
+ if (service is FurnitureComponentForm form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Добавление нового компонента:{ ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ if (_furnitureComponents.ContainsKey(form.Id))
+ {
+ _furnitureComponents[form.Id] = (form.ComponentModel, form.Count);
+ }
+ else
+ {
+ _furnitureComponents.Add(form.Id, (form.ComponentModel, form.Count));
+ }
+ LoadData();
+ }
+ }
+
+ }
+
+ private void buttonChange_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FurnitureComponentForm));
+ if (service is FurnitureComponentForm form)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
+ form.Id = id;
+ form.Count = _furnitureComponents[id].Item2;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ if (form.ComponentModel == null)
+ {
+ return;
+ }
+ _logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
+ _furnitureComponents[form.Id] = (form.ComponentModel, form.Count);
+ LoadData();
+ }
+ }
+ }
+
+ }
+
+ private void buttonDelete_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);
+ _furnitureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+
+ }
+
+ private void buttonUpdate_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 (_furnitureComponents == null || _furnitureComponents.Count == 0)
+ {
+ MessageBox.Show("Заполните компоненты", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение изделия");
+ try
+ {
+ var model = new FurnitureBindingModel
+ {
+ Id = _id ?? 0,
+ FurnitureName = textBoxName.Text,
+ Price = Convert.ToDouble(textBoxPrice.Text),
+ FurnitureComponents = _furnitureComponents
+ };
+ 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 _furnitureComponents)
+ {
+ price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
+ }
+ return Math.Round(price * 1.1, 2);
+ }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssembly/FurnitureForm.resx b/FurnitureAssembly/FurnitureAssembly/FurnitureForm.resx
new file mode 100644
index 0000000..83495f9
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnitureForm.resx
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ True
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/FurnituresForm.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FurnituresForm.Designer.cs
new file mode 100644
index 0000000..ccad5da
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnituresForm.Designer.cs
@@ -0,0 +1,115 @@
+namespace FurnitureAssemblyView
+{
+ partial class FurnituresForm
+ {
+ ///
+ /// 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.AddButton = new System.Windows.Forms.Button();
+ this.ChangeButton = new System.Windows.Forms.Button();
+ this.DeleteButton = new System.Windows.Forms.Button();
+ this.UpdateButton = 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(1, 1);
+ this.DataGridView.Name = "DataGridView";
+ this.DataGridView.RowHeadersWidth = 62;
+ this.DataGridView.RowTemplate.Height = 25;
+ this.DataGridView.Size = new System.Drawing.Size(418, 328);
+ this.DataGridView.TabIndex = 0;
+ //
+ // AddButton
+ //
+ this.AddButton.Location = new System.Drawing.Point(430, 7);
+ this.AddButton.Name = "AddButton";
+ this.AddButton.Size = new System.Drawing.Size(120, 23);
+ this.AddButton.TabIndex = 1;
+ this.AddButton.Text = "Добавить";
+ this.AddButton.UseVisualStyleBackColor = true;
+ this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
+ //
+ // ChangeButton
+ //
+ this.ChangeButton.Location = new System.Drawing.Point(430, 66);
+ this.ChangeButton.Name = "ChangeButton";
+ this.ChangeButton.Size = new System.Drawing.Size(120, 23);
+ this.ChangeButton.TabIndex = 2;
+ this.ChangeButton.Text = "Изменить";
+ this.ChangeButton.UseVisualStyleBackColor = true;
+ this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
+ //
+ // DeleteButton
+ //
+ this.DeleteButton.Location = new System.Drawing.Point(430, 125);
+ this.DeleteButton.Name = "DeleteButton";
+ this.DeleteButton.Size = new System.Drawing.Size(120, 23);
+ this.DeleteButton.TabIndex = 3;
+ this.DeleteButton.Text = "Удалить";
+ this.DeleteButton.UseVisualStyleBackColor = true;
+ this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
+ //
+ // UpdateButton
+ //
+ this.UpdateButton.Location = new System.Drawing.Point(430, 186);
+ this.UpdateButton.Name = "UpdateButton";
+ this.UpdateButton.Size = new System.Drawing.Size(120, 23);
+ this.UpdateButton.TabIndex = 4;
+ this.UpdateButton.Text = "Обновить";
+ this.UpdateButton.UseVisualStyleBackColor = true;
+ this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
+ //
+ // FurnituresForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(564, 338);
+ this.Controls.Add(this.UpdateButton);
+ this.Controls.Add(this.DeleteButton);
+ this.Controls.Add(this.ChangeButton);
+ this.Controls.Add(this.AddButton);
+ this.Controls.Add(this.DataGridView);
+ this.Name = "FurnituresForm";
+ this.Text = "Изделия";
+ this.Load += new System.EventHandler(this.FurnituresForm_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView DataGridView;
+ private Button AddButton;
+ private Button ChangeButton;
+ private Button DeleteButton;
+ private Button UpdateButton;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/FurnituresForm.cs b/FurnitureAssembly/FurnitureAssembly/FurnituresForm.cs
new file mode 100644
index 0000000..946960b
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnituresForm.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using FurnitureAssembly;
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyView;
+using Microsoft.Extensions.Logging;
+
+namespace FurnitureAssemblyView
+{
+ public partial class FurnituresForm : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IfurnitureLogic _logic;
+
+ public FurnituresForm(ILogger logger, IfurnitureLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var list = _logic.ReadList(null);
+
+ if (list != null)
+ {
+ DataGridView.DataSource = list;
+ DataGridView.Columns["Id"].Visible = false;
+ DataGridView.Columns["FurnitureComponents"].Visible = false;
+ DataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+
+ _logger.LogInformation("Загрузка компонентов");
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки компонентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FurnitureForm));
+
+ if (service is FurnitureForm form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ChangeButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FurnitureForm));
+
+ if (service is FurnitureForm form)
+ {
+ form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void DeleteButton_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 FurnitureBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления компонента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+
+ private void FurnituresForm_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssembly/FurnituresForm.resx b/FurnitureAssembly/FurnitureAssembly/FurnituresForm.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/FurnituresForm.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/FurnitureAssembly/FurnitureAssembly/MainForm.Designer.cs b/FurnitureAssembly/FurnitureAssembly/MainForm.Designer.cs
new file mode 100644
index 0000000..5daac66
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/MainForm.Designer.cs
@@ -0,0 +1,176 @@
+namespace FurnitureAssemblyView
+{
+ partial class MainForm
+ {
+ ///
+ /// 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()
+ {
+ System.Windows.Forms.Button buttonReady;
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.buttonToWork = new System.Windows.Forms.Button();
+ 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();
+ buttonReady = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.menuStrip.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // buttonReady
+ //
+ buttonReady.Location = new System.Drawing.Point(1273, 225);
+ buttonReady.Name = "buttonReady";
+ buttonReady.Size = new System.Drawing.Size(215, 34);
+ buttonReady.TabIndex = 3;
+ buttonReady.Text = "Заказ готов";
+ buttonReady.UseVisualStyleBackColor = true;
+ buttonReady.Click += new System.EventHandler(this.buttonReady_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(9, 52);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 62;
+ this.dataGridView.RowTemplate.Height = 33;
+ this.dataGridView.Size = new System.Drawing.Size(1227, 386);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.Location = new System.Drawing.Point(1273, 52);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(215, 34);
+ this.buttonCreate.TabIndex = 1;
+ this.buttonCreate.Text = "Создать заказ";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
+ //
+ // buttonToWork
+ //
+ this.buttonToWork.Location = new System.Drawing.Point(1273, 137);
+ this.buttonToWork.Name = "buttonToWork";
+ this.buttonToWork.Size = new System.Drawing.Size(215, 34);
+ this.buttonToWork.TabIndex = 2;
+ this.buttonToWork.Text = "Отдать на выполнение";
+ this.buttonToWork.UseVisualStyleBackColor = true;
+ this.buttonToWork.Click += new System.EventHandler(this.buttonToWork_Click);
+ //
+ // buttonPut
+ //
+ this.buttonPut.Location = new System.Drawing.Point(1273, 308);
+ this.buttonPut.Name = "buttonPut";
+ this.buttonPut.Size = new System.Drawing.Size(215, 34);
+ this.buttonPut.TabIndex = 4;
+ this.buttonPut.Text = "Заказ выдан";
+ this.buttonPut.UseVisualStyleBackColor = true;
+ this.buttonPut.Click += new System.EventHandler(this.buttonPut_Click);
+ //
+ // buttonRefresh
+ //
+ this.buttonRefresh.Location = new System.Drawing.Point(1273, 389);
+ this.buttonRefresh.Name = "buttonRefresh";
+ this.buttonRefresh.Size = new System.Drawing.Size(215, 34);
+ this.buttonRefresh.TabIndex = 5;
+ this.buttonRefresh.Text = "Обновить список";
+ this.buttonRefresh.UseVisualStyleBackColor = true;
+ this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click);
+ //
+ // menuStrip
+ //
+ this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
+ 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(1530, 33);
+ this.menuStrip.TabIndex = 6;
+ 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(139, 29);
+ this.справочникиToolStripMenuItem.Text = "Справочники";
+ //
+ // компонентыToolStripMenuItem
+ //
+ this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
+ this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
+ this.компонентыToolStripMenuItem.Text = "Компоненты";
+ this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
+ //
+ // изделияToolStripMenuItem
+ //
+ this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
+ this.изделияToolStripMenuItem.Size = new System.Drawing.Size(218, 34);
+ this.изделияToolStripMenuItem.Text = "Изделия";
+ this.изделияToolStripMenuItem.Click += new System.EventHandler(this.изделияToolStripMenuItem_Click);
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1530, 450);
+ this.Controls.Add(this.buttonRefresh);
+ this.Controls.Add(this.buttonPut);
+ this.Controls.Add(buttonReady);
+ this.Controls.Add(this.buttonToWork);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
+ this.Name = "MainForm";
+ this.Text = "Сборка мебели";
+ this.Load += new System.EventHandler(this.MainForm_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonCreate;
+ private Button buttonToWork;
+ private Button buttonPut;
+ private Button buttonRefresh;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem справочникиToolStripMenuItem;
+ private ToolStripMenuItem компонентыToolStripMenuItem;
+ private ToolStripMenuItem изделияToolStripMenuItem;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/MainForm.cs b/FurnitureAssembly/FurnitureAssembly/MainForm.cs
new file mode 100644
index 0000000..ec37db9
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/MainForm.cs
@@ -0,0 +1,190 @@
+using FurnitureAssemblyDataModels.Enums;
+using FurnitureAssembly;
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FurnitureAssemblyView
+{
+ public partial class MainForm : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+
+ public MainForm(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+
+ }
+
+ private void MainForm_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["FurnitureId"].Visible = false;
+ }
+
+ _logger.LogInformation("Загрузка заказов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(ComponentsForm));
+ if (service is ComponentsForm form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void изделияToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FurnituresForm));
+
+ if (service is FurnituresForm form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(OrderForm));
+ if (service is OrderForm form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void buttonToWork_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,
+ FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value),
+ 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 buttonReady_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,
+ FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value),
+ 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 buttonPut_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,
+ FurnitureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["FurnitureId"].Value),
+ 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 buttonRefresh_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssembly/MainForm.resx b/FurnitureAssembly/FurnitureAssembly/MainForm.resx
new file mode 100644
index 0000000..1eca966
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/MainForm.resx
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ False
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/OrderForm.Designer.cs b/FurnitureAssembly/FurnitureAssembly/OrderForm.Designer.cs
new file mode 100644
index 0000000..ce7e6ce
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/OrderForm.Designer.cs
@@ -0,0 +1,144 @@
+namespace FurnitureAssemblyView
+{
+ partial class OrderForm
+ {
+ ///
+ /// 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.comboBoxFurniture = new System.Windows.Forms.ComboBox();
+ this.labelFurniture = new System.Windows.Forms.Label();
+ this.labelCount = new System.Windows.Forms.Label();
+ this.labelSum = new System.Windows.Forms.Label();
+ this.textBoxCount = new System.Windows.Forms.TextBox();
+ this.textBoxSum = new System.Windows.Forms.TextBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.buttonCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // comboBoxFurniture
+ //
+ this.comboBoxFurniture.FormattingEnabled = true;
+ this.comboBoxFurniture.Location = new System.Drawing.Point(115, 14);
+ this.comboBoxFurniture.Name = "comboBoxFurniture";
+ this.comboBoxFurniture.Size = new System.Drawing.Size(250, 33);
+ this.comboBoxFurniture.TabIndex = 0;
+ //
+ // labelFurniture
+ //
+ this.labelFurniture.AutoSize = true;
+ this.labelFurniture.Location = new System.Drawing.Point(12, 22);
+ this.labelFurniture.Name = "labelFurniture";
+ this.labelFurniture.Size = new System.Drawing.Size(80, 25);
+ this.labelFurniture.TabIndex = 1;
+ this.labelFurniture.Text = "Изделие";
+ //
+ // labelCount
+ //
+ this.labelCount.AutoSize = true;
+ this.labelCount.Location = new System.Drawing.Point(12, 67);
+ this.labelCount.Name = "labelCount";
+ this.labelCount.Size = new System.Drawing.Size(107, 25);
+ this.labelCount.TabIndex = 2;
+ this.labelCount.Text = "Количество";
+ //
+ // labelSum
+ //
+ this.labelSum.AutoSize = true;
+ this.labelSum.Location = new System.Drawing.Point(12, 118);
+ this.labelSum.Name = "labelSum";
+ this.labelSum.Size = new System.Drawing.Size(67, 25);
+ this.labelSum.TabIndex = 3;
+ this.labelSum.Text = "Сумма";
+ //
+ // textBoxCount
+ //
+ this.textBoxCount.Location = new System.Drawing.Point(115, 64);
+ this.textBoxCount.Name = "textBoxCount";
+ this.textBoxCount.Size = new System.Drawing.Size(250, 31);
+ this.textBoxCount.TabIndex = 4;
+ this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCount_TextChanged);
+ //
+ // textBoxSum
+ //
+ this.textBoxSum.Location = new System.Drawing.Point(115, 115);
+ this.textBoxSum.Name = "textBoxSum";
+ this.textBoxSum.ReadOnly = true;
+ this.textBoxSum.Size = new System.Drawing.Size(250, 31);
+ this.textBoxSum.TabIndex = 5;
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(31, 161);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(112, 34);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Сохранить";
+ this.buttonSave.UseVisualStyleBackColor = true;
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // buttonCancel
+ //
+ this.buttonCancel.Location = new System.Drawing.Point(253, 161);
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.Size = new System.Drawing.Size(112, 34);
+ this.buttonCancel.TabIndex = 7;
+ this.buttonCancel.Text = "Отмена";
+ this.buttonCancel.UseVisualStyleBackColor = true;
+ this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
+ //
+ // OrderForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(401, 207);
+ this.Controls.Add(this.buttonCancel);
+ this.Controls.Add(this.buttonSave);
+ this.Controls.Add(this.textBoxSum);
+ this.Controls.Add(this.textBoxCount);
+ this.Controls.Add(this.labelSum);
+ this.Controls.Add(this.labelCount);
+ this.Controls.Add(this.labelFurniture);
+ this.Controls.Add(this.comboBoxFurniture);
+ this.Name = "OrderForm";
+ this.Text = "Заказ";
+ this.Load += new System.EventHandler(this.OrderForm_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private ComboBox comboBoxFurniture;
+ private Label labelFurniture;
+ private Label labelCount;
+ private Label labelSum;
+ private TextBox textBoxCount;
+ private TextBox textBoxSum;
+ private Button buttonSave;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssembly/OrderForm.cs b/FurnitureAssembly/FurnitureAssembly/OrderForm.cs
new file mode 100644
index 0000000..e28de03
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/OrderForm.cs
@@ -0,0 +1,126 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace FurnitureAssemblyView
+{
+ public partial class OrderForm : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IfurnitureLogic _logicP;
+ private readonly IOrderLogic _logicO;
+ public OrderForm(ILogger logger, IfurnitureLogic logicP, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicO = logicO;
+ }
+
+ private void OrderForm_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка изделий для заказа");
+ try
+ {
+ var list = _logicP.ReadList(null);
+ if (list != null)
+ {
+ comboBoxFurniture.DisplayMember = "FurnitureName";
+ comboBoxFurniture.ValueMember = "Id";
+ comboBoxFurniture.DataSource = list;
+ comboBoxFurniture.SelectedItem = null;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки списка изделий");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void CalcSum()
+ {
+ if (comboBoxFurniture.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxFurniture.SelectedIndex)+1;
+ var furniture = _logicP.ReadElement(new FurnitureSearchModel
+ {
+ Id = id
+ });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (furniture?.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 buttonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ MessageBox.Show("Заполните поле Количество", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ if (comboBoxFurniture.SelectedValue == null)
+ {
+ MessageBox.Show("Выберите изделие", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.CreateOrder(new OrderBindingModel
+ {
+ FurnitureId = Convert.ToInt32(comboBoxFurniture.SelectedIndex)+1,
+ 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/FurnitureAssembly/FurnitureAssembly/OrderForm.resx b/FurnitureAssembly/FurnitureAssembly/OrderForm.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/OrderForm.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/FurnitureAssembly/FurnitureAssembly/Program.cs b/FurnitureAssembly/FurnitureAssembly/Program.cs
new file mode 100644
index 0000000..7656364
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssembly/Program.cs
@@ -0,0 +1,53 @@
+using FurnitureAssemblyContracts.StoragesContracts;
+using Microsoft.Extensions.DependencyInjection;
+using FurnitureAssemblyListImplement.Implements;
+using FurnitureAssemblyBusinessLogic.BusinessLogics;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using AbstractShopBusinessLogic.BusinessLogics;
+using NLog.Extensions.Logging;
+using FurnitureAssemblyView;
+using Microsoft.Extensions.Logging;
+
+namespace FurnitureAssembly
+{
+ 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();
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/ComponentLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/ComponentLogic.cs
new file mode 100644
index 0000000..b75b9b2
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/ComponentLogic.cs
@@ -0,0 +1,113 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace FurnitureAssemblyBusinessLogic.BusinessLogics
+{
+ public class ComponentLogic : IComponentLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentStorage _componentStorage;
+ public ComponentLogic(ILogger logger, IComponentStorage
+ componentStorage)
+ {
+ _logger = logger;
+ _componentStorage = componentStorage;
+ }
+ public List? ReadList(ComponentSearchModel? 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");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public ComponentViewModel? ReadElement(ComponentSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(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");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
+ return element;
+ }
+ public bool Create(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ComponentBindingModel model)
+ {
+ CheckModel(model);
+ if (_componentStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ComponentBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_componentStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(ComponentBindingModel model, bool withParams =
+ true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.ComponentName))
+ {
+ throw new ArgumentNullException("Нет названия компонента",
+ nameof(model.ComponentName));
+ }
+ if (model.Cost <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
+ }
+ _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: {Id}", model.ComponentName, model.Cost, model.Id);
+ var element = _componentStorage.GetElement(new ComponentSearchModel
+ {
+ ComponentName = model.ComponentName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Компонент с таким названием уже есть");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/FurnitureLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/FurnitureLogic.cs
new file mode 100644
index 0000000..e8b1fee
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/FurnitureLogic.cs
@@ -0,0 +1,114 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractShopBusinessLogic.BusinessLogics
+{
+ public class FurnitureLogic: IfurnitureLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IFurnitureStorage _FurnitureStorage;
+ public FurnitureLogic(ILogger logger, IFurnitureStorage furnitureStorage)
+ {
+ _logger = logger;
+ _FurnitureStorage = furnitureStorage;
+ }
+ public List? ReadList(FurnitureSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. FurnitureName:{FurnitureName}.Id:{Id}", model?.FurnitureName, model?.Id);
+ var list = model == null ? _FurnitureStorage.GetFullList() : _FurnitureStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+ public FurnitureViewModel? ReadElement(FurnitureSearchModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ _logger.LogInformation("ReadElement. FurnitureName:{FurnitureName}.Id:{Id}", model.FurnitureName, model.Id);
+
+ var element = _FurnitureStorage.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(FurnitureBindingModel model)
+ {
+ CheckModel(model);
+ if (_FurnitureStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(FurnitureBindingModel model)
+ {
+ CheckModel(model);
+ if (_FurnitureStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(FurnitureBindingModel model)
+ {
+ CheckModel(model, false);
+ _logger.LogInformation("Delete. Id:{Id}", model.Id);
+ if (_FurnitureStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ private void CheckModel(FurnitureBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (!withParams)
+ {
+ return;
+ }
+ if (string.IsNullOrEmpty(model.FurnitureName))
+ {
+ throw new ArgumentNullException("Нет названия продукта",nameof(model.FurnitureName));
+ }
+ if (model.Price <= 0)
+ {
+ throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Price));
+ }
+ _logger.LogInformation("Furniture. FurnitureName:{FurnitureName}. Price:{Price}. Id: {Id}", model.FurnitureName, model.Price, model.Id);
+ var element = _FurnitureStorage.GetElement(new FurnitureSearchModel
+ {
+ FurnitureName = model.FurnitureName
+ });
+ if (element != null && element.Id != model.Id)
+ {
+ throw new InvalidOperationException("Изделие с таким названием уже есть");
+ }
+ }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/OrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/OrderLogic.cs
new file mode 100644
index 0000000..6d7ea5d
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -0,0 +1,132 @@
+using FurnitureAssemblyDataModels.Enums;
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.BusinessLogicsContracts;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AbstractShopBusinessLogic.BusinessLogics
+{
+ public class OrderLogic : IOrderLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderStorage _orderStorage;
+ public OrderLogic(ILogger logger, IOrderStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+
+ public bool CreateOrder(OrderBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != OrderStatus.Неизвестен) return false;
+ model.Status = OrderStatus.Принят;
+ if (_orderStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool DeliveryOrder(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Выдан);
+ }
+
+ public bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
+ {
+ var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
+ if (viewModel == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+ if (viewModel.Status + 1 != newStatus)
+ {
+ _logger.LogWarning("Change status operation failed");
+ return false;
+ }
+ model.Status = newStatus;
+ model.FurnitureId = viewModel.FurnitureId;
+ model.Count = viewModel.Count;
+ model.Sum = viewModel.Sum;
+ model.DateCreate = viewModel.DateCreate;
+ if (model.Status == OrderStatus.Готов)
+ {
+ model.DateImplement = DateTime.Now;
+ }
+ else
+ {
+ model.DateImplement = viewModel.DateImplement;
+ }
+ CheckModel(model, false);
+ if (_orderStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Change status operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public bool FinishOrder(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Готов);
+ }
+
+ public List? ReadList(OrderSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. OrderId:{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 TakeOrderInWork(OrderBindingModel model)
+ {
+ return ChangeStatus(model, OrderStatus.Выполняется);
+ }
+
+ private void CheckModel(OrderBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if (!withParams)
+ {
+ return;
+ }
+
+ if (model.FurnitureId < 0)
+ {
+ throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.FurnitureId));
+ }
+
+ 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}. PackageId: { PackageId}", model.Id, model.Sum, model.FurnitureId);
+ }
+
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj
new file mode 100644
index 0000000..4358031
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyBusinessLogic/FurnitureAssemblyBusinessLogic.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs
new file mode 100644
index 0000000..2fd80bb
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/ComponentBindingModel.cs
@@ -0,0 +1,16 @@
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BindingModels
+{
+ public class ComponentBindingModel : IComponentModel
+ {
+ public int Id { get; set; }
+ public string ComponentName { get; set; } = string.Empty;
+ public double Cost { get; set; }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureBindingModel.cs
new file mode 100644
index 0000000..f68be66
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/FurnitureBindingModel.cs
@@ -0,0 +1,17 @@
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BindingModels
+{
+ public class FurnitureBindingModel : IFurnitureModel
+ {
+ public int Id { get; set; }
+ public string FurnitureName { get; set; } = string.Empty;
+ public double Price { get; set; }
+ public Dictionary FurnitureComponents {get; set;} = new();
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs
new file mode 100644
index 0000000..280e941
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/BindingModels/OrderBindingModel.cs
@@ -0,0 +1,21 @@
+using FurnitureAssemblyDataModels.Enums;
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BindingModels
+{
+ public class OrderBindingModel : IOrderModel
+ {
+ public int Id { get; set; }
+ public int FurnitureId { get; set; }
+ 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; }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IComponentLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IComponentLogic.cs
new file mode 100644
index 0000000..08bc7a4
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IComponentLogic.cs
@@ -0,0 +1,20 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IFurnitureLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IFurnitureLogic.cs
new file mode 100644
index 0000000..089bb33
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IFurnitureLogic.cs
@@ -0,0 +1,20 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.BusinessLogicsContracts
+{
+ public interface IfurnitureLogic
+ {
+ List? ReadList(FurnitureSearchModel? model);
+ FurnitureViewModel? ReadElement(FurnitureSearchModel model);
+ bool Create(FurnitureBindingModel model);
+ bool Update(FurnitureBindingModel model);
+ bool Delete(FurnitureBindingModel model);
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IOrderLogic.cs b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IOrderLogic.cs
new file mode 100644
index 0000000..179f3f7
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/BusinessLogicsContracts/IOrderLogic.cs
@@ -0,0 +1,20 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj b/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj
new file mode 100644
index 0000000..c45b9a0
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/FurnitureAssemblyContracts.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs
new file mode 100644
index 0000000..4062244
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/ComponentSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.SearchModels
+{
+ public class ComponentSearchModel
+ {
+ public int? Id { get; set; }
+ public string? ComponentName { get; set; }
+ }
+
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureSearchModel.cs
new file mode 100644
index 0000000..e4bd1aa
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/FurnitureSearchModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.SearchModels
+{
+ public class FurnitureSearchModel
+ {
+ public int? Id { get; set; }
+ public string? FurnitureName { get; set; }
+ }
+
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs
new file mode 100644
index 0000000..25dba07
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/SearchModels/OrderSearchModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.SearchModels
+{
+ public class OrderSearchModel
+ {
+ public int? Id { get; set; }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs
new file mode 100644
index 0000000..22a17d8
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IComponentStorage.cs
@@ -0,0 +1,21 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IFurnitureStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IFurnitureStorage.cs
new file mode 100644
index 0000000..e858507
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IFurnitureStorage.cs
@@ -0,0 +1,22 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.StoragesContracts
+{
+ public interface IFurnitureStorage
+ {
+ List GetFullList();
+ List GetFilteredList(FurnitureSearchModel model);
+ FurnitureViewModel? GetElement(FurnitureSearchModel model);
+ FurnitureViewModel? Insert(FurnitureBindingModel model);
+ FurnitureViewModel? Update(FurnitureBindingModel model);
+ FurnitureViewModel? Delete(FurnitureBindingModel model);
+ }
+
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs
new file mode 100644
index 0000000..fd843e7
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/StoragesContracts/IOrderStorage.cs
@@ -0,0 +1,21 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs
new file mode 100644
index 0000000..516ff28
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs
@@ -0,0 +1,19 @@
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.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/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs
new file mode 100644
index 0000000..f0a1775
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs
@@ -0,0 +1,21 @@
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.ViewModels
+{
+ public class FurnitureViewModel : IFurnitureModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название изделия")]
+ public string FurnitureName { get; set; } = string.Empty;
+ [DisplayName("Цена")]
+ public double Price { get; set; }
+ public Dictionary FurnitureComponents { get; set; } = new();
+ }
+
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs
new file mode 100644
index 0000000..423ecaf
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs
@@ -0,0 +1,30 @@
+using FurnitureAssemblyDataModels.Enums;
+using FurnitureAssemblyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyContracts.ViewModels
+{
+ public class OrderViewModel : IOrderModel
+ {
+ [DisplayName("Номер")]
+ public int Id { get; set; }
+ public int FurnitureId { get; set; }
+ [DisplayName("Изделие")]
+ public string FurnitureName { 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; }
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/AbstractFurnitureAssemblyDataModels.sln b/FurnitureAssembly/FurnitureAssemblyDataModels/AbstractFurnitureAssemblyDataModels.sln
new file mode 100644
index 0000000..0261921
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyDataModels/AbstractFurnitureAssemblyDataModels.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32210.238
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractFurnitureAssemblyDataModels", "AbstractFurnitureAssemblyDataModels.csproj", "{4844106A-4EBA-4EE0-906B-4CC2B4482C2D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4844106A-4EBA-4EE0-906B-4CC2B4482C2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4844106A-4EBA-4EE0-906B-4CC2B4482C2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4844106A-4EBA-4EE0-906B-4CC2B4482C2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4844106A-4EBA-4EE0-906B-4CC2B4482C2D}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {5BCF4DD3-B5C7-498A-B8C9-D7C09179AFB1}
+ EndGlobalSection
+EndGlobal
diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Enums/OrderStatus.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Enums/OrderStatus.cs
new file mode 100644
index 0000000..0f80752
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Enums/OrderStatus.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels.Enums
+{
+ public enum OrderStatus
+ {
+ Неизвестен = -1,
+ Принят = 0,
+ Выполняется = 1,
+ Готов = 2,
+ Выдан = 3
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj b/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj
new file mode 100644
index 0000000..27ac386
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyDataModels/FurnitureAssemblyDataModels.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Interface.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Interface.cs
new file mode 100644
index 0000000..72a5c28
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Interface.cs
@@ -0,0 +1,8 @@
+namespace FurnitureAssemblyDataModels
+{
+ public interface IId
+ {
+ int Id { get; }
+ }
+
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IComponentModel.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IComponentModel.cs
new file mode 100644
index 0000000..fd187a2
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IComponentModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels.Models
+{
+ public interface IComponentModel : IId
+ {
+ string ComponentName { get; }
+ double Cost { get; }
+ }
+
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IFurnitureModel.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IFurnitureModel.cs
new file mode 100644
index 0000000..217f579
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IFurnitureModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels.Models
+{
+ public interface IFurnitureModel : IId
+ {
+ string FurnitureName { get; }
+ double Price { get; }
+ Dictionary FurnitureComponents { get; }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IOrderModel.cs b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IOrderModel.cs
new file mode 100644
index 0000000..6334ef8
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyDataModels/Models/IOrderModel.cs
@@ -0,0 +1,19 @@
+using FurnitureAssemblyDataModels.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyDataModels.Models
+{
+ public interface IOrderModel : IId
+ {
+ int FurnitureId { get; }
+ int Count { get; }
+ double Sum { get; }
+ OrderStatus Status { get; }
+ DateTime DateCreate { get; }
+ DateTime? DateImplement { get; }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs
new file mode 100644
index 0000000..1d358c2
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyListImplement/DataListSingleton.cs
@@ -0,0 +1,26 @@
+using FurnitureAssemblyListImplement.Models;
+
+namespace FurnitureAssemblyListImplement
+{
+ public class DataListSingleton
+ {
+ private static DataListSingleton? _instance;
+ public List Components { get; set; }
+ public List Orders { get; set; }
+ public List Furnitures { get; set; }
+ private DataListSingleton()
+ {
+ Components = new List();
+ Orders = new List();
+ Furnitures = new List();
+ }
+ public static DataListSingleton GetInstance()
+ {
+ if (_instance == null)
+ {
+ _instance = new DataListSingleton();
+ }
+ return _instance;
+ }
+ }
+}
\ No newline at end of file
diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj b/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj
new file mode 100644
index 0000000..00764bc
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyListImplement/FurnitureAssemblyListImplement.csproj
@@ -0,0 +1,15 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs
new file mode 100644
index 0000000..c022f3a
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/ComponentStorage.cs
@@ -0,0 +1,108 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.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;
+ }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/FurnitureStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/FurnitureStorage.cs
new file mode 100644
index 0000000..a3bc360
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/FurnitureStorage.cs
@@ -0,0 +1,112 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Implements
+{
+ public class FurnitureStorage : IFurnitureStorage
+ {
+ private readonly DataListSingleton _source;
+ public FurnitureStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ public FurnitureViewModel? Delete(FurnitureBindingModel model)
+ {
+ for (int i = 0; i < _source.Furnitures.Count; ++i)
+ {
+ if (_source.Furnitures[i].Id == model.Id)
+ {
+ var element = _source.Furnitures[i];
+ _source.Furnitures.RemoveAt(i);
+ return element.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public FurnitureViewModel? GetElement(FurnitureSearchModel model)
+ {
+ if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue)
+ {
+ return null;
+ }
+ foreach (var furniture in _source.Furnitures)
+ {
+ if ((!string.IsNullOrEmpty(model.FurnitureName) &&
+ furniture.FurnitureName == model.FurnitureName) ||
+ (model.Id.HasValue && furniture.Id == model.Id))
+ {
+ return furniture.GetViewModel;
+ }
+ }
+ return null;
+ }
+
+ public List GetFilteredList(FurnitureSearchModel model)
+ {
+ var result = new List();
+ if (string.IsNullOrEmpty(model.FurnitureName))
+ {
+ return result;
+ }
+ foreach (var furniture in _source.Furnitures)
+ {
+ if (furniture.FurnitureName.Contains(model.FurnitureName))
+ {
+ result.Add(furniture.GetViewModel);
+ }
+ }
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var furniture in _source.Furnitures)
+ {
+ result.Add(furniture.GetViewModel);
+ }
+ return result;
+ }
+
+ public FurnitureViewModel? Insert(FurnitureBindingModel model)
+ {
+ model.Id = 1;
+ foreach (var furniture in _source.Furnitures)
+ {
+ if (model.Id <= furniture.Id)
+ {
+ model.Id = furniture.Id + 1;
+ }
+ }
+ var newFurniture = Furniture.Create(model);
+ if (newFurniture == null)
+ {
+ return null;
+ }
+ _source.Furnitures.Add(newFurniture);
+ return newFurniture.GetViewModel;
+ }
+
+ public FurnitureViewModel? Update(FurnitureBindingModel model)
+ {
+ foreach (var furniture in _source.Furnitures)
+ {
+ if (furniture.Id == model.Id)
+ {
+ furniture.Update(model);
+ return furniture.GetViewModel;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs
new file mode 100644
index 0000000..1cf2889
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Implements/OrderStorage.cs
@@ -0,0 +1,123 @@
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.SearchModels;
+using FurnitureAssemblyContracts.StoragesContracts;
+using FurnitureAssemblyContracts.ViewModels;
+using FurnitureAssemblyListImplement.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Implements
+{
+ public class OrderStorage : IOrderStorage
+ {
+ private readonly DataListSingleton _source;
+ public OrderStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+ 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 GetViewModel(element);
+ }
+ }
+ return null;
+ }
+
+ 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 GetViewModel(order);
+ }
+ }
+ return null;
+ }
+
+ public List GetFilteredList(OrderSearchModel model)
+ {
+ var result = new List();
+ if (model == null)
+ {
+ return result;
+ }
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ result.Add(GetViewModel(order));
+ }
+ }
+ return result;
+ }
+
+ public List GetFullList()
+ {
+ var result = new List();
+ foreach (var order in _source.Orders)
+ {
+ result.Add(GetViewModel(order));
+ }
+ return result;
+ }
+
+ 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 GetViewModel(newOrder);
+ }
+
+ public OrderViewModel? Update(OrderBindingModel model)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.Id == model.Id)
+ {
+ order.Update(model);
+ return order.GetViewModel;
+ }
+ }
+ return null;
+ }
+ private OrderViewModel GetViewModel(Order order)
+ {
+ var viewModel = order.GetViewModel;
+ foreach (var furniture in _source.Furnitures)
+ {
+ if (furniture.Id == order.FurnitureId)
+ {
+ viewModel.FurnitureName = furniture.FurnitureName;
+ break;
+ }
+ }
+ return viewModel;
+ }
+ }
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Component.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Component.cs
new file mode 100644
index 0000000..a0d642a
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Component.cs
@@ -0,0 +1,48 @@
+using FurnitureAssemblyDataModels.Models;
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.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
+ };
+ }
+
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Furniture.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Furniture.cs
new file mode 100644
index 0000000..ae65bc3
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Furniture.cs
@@ -0,0 +1,55 @@
+using FurnitureAssemblyDataModels.Models;
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Models
+{
+ public class Furniture : IFurnitureModel
+ {
+ public int Id { get; private set; }
+ public string FurnitureName { get; private set; } = string.Empty;
+ public double Price { get; private set; }
+ public Dictionary FurnitureComponents
+ {
+ get;
+ private set;
+ } = new Dictionary();
+ public static Furniture? Create(FurnitureBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Furniture()
+ {
+ Id = model.Id,
+ FurnitureName = model.FurnitureName,
+ Price = model.Price,
+ FurnitureComponents = model.FurnitureComponents
+ };
+ }
+ public void Update(FurnitureBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ FurnitureName = model.FurnitureName;
+ Price = model.Price;
+ FurnitureComponents = model.FurnitureComponents;
+ }
+ public FurnitureViewModel GetViewModel => new()
+ {
+ Id = Id,
+ FurnitureName = FurnitureName,
+ Price = Price,
+ FurnitureComponents = FurnitureComponents
+ };
+ }
+
+}
diff --git a/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs
new file mode 100644
index 0000000..c71017c
--- /dev/null
+++ b/FurnitureAssembly/FurnitureAssemblyListImplement/Models/Order.cs
@@ -0,0 +1,65 @@
+using FurnitureAssemblyDataModels.Enums;
+using FurnitureAssemblyDataModels.Models;
+using FurnitureAssemblyContracts.BindingModels;
+using FurnitureAssemblyContracts.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FurnitureAssemblyListImplement.Models
+{
+ public class Order : IOrderModel
+ {
+ public int FurnitureId { get; private set; }
+
+ public int Count { get; private set; }
+
+ public double Sum { get; private set; }
+
+ public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
+
+ public DateTime DateCreate { get; private set; } = DateTime.Now;
+
+ public DateTime? DateImplement { get; private set; }
+
+ public int Id { get; private set; }
+ public static Order? Create(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Order()
+ {
+ Id = model.Id,
+ FurnitureId = model.FurnitureId,
+ Count = model.Count,
+ Sum = model.Sum,
+ Status = model.Status,
+ DateCreate = model.DateCreate,
+ DateImplement = model.DateImplement
+ };
+ }
+ public void Update(OrderBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Status = model.Status;
+ DateImplement = model.DateImplement;
+ }
+ public OrderViewModel GetViewModel => new()
+ {
+ Id = Id,
+ FurnitureId = FurnitureId,
+ Count = Count,
+ Sum = Sum,
+ Status = Status,
+ DateCreate = DateCreate,
+ DateImplement = DateImplement
+ };
+ }
+}